Computer Science Canada

Anyone have a good working Pong game?

Author:  juniorspank [ Tue Nov 25, 2003 4:41 pm ]
Post subject:  Anyone have a good working Pong game?

I was just wondering because I've been looking for one. That or Light Cycles. Head Bang

Author:  Andy [ Tue Nov 25, 2003 4:47 pm ]
Post subject: 

http://www.compsci.ca/v2/viewtopic.php?t=914

my pong, only exe tho

Author:  juniorspank [ Tue Nov 25, 2003 4:52 pm ]
Post subject:  Thanks

Thanks, it is very much appreciated.

Author:  roer [ Tue Nov 25, 2003 6:24 pm ]
Post subject: 

Dodge I'm in the process in making a pong game myself but I don't know how to make Turing recognize the Draw.Box as function of some sort so I can call on it. I've been studying Turing for about a week now and I don't really want an answer, just a hint of somesort. Thanks

Author:  AsianSensation [ Tue Nov 25, 2003 7:28 pm ]
Post subject: 

lol, get your turing updated, go to holtsoft and download their patch, this will have that problem fixed.

If you don't want to or can't download for some reason, use drawbox () instead.

Author:  roer [ Tue Nov 25, 2003 7:33 pm ]
Post subject: 

I know how to draw the box, I have v4.0.4 at school. I was just wondering once you draw the box, how do you call on it later? If I draw the box how do I declare it? Sorry if it seems like a really newbish question Embarassed

Author:  Tony [ Tue Nov 25, 2003 7:38 pm ]
Post subject: 

oh, lol. Box is not an object, its just a graphic that is put on the screen. You can't do anything with it, but to draw something over it to make the box disappear Laughing

sorry to break this to you - but Turing sucks when it comes to programming.

Author:  roer [ Tue Nov 25, 2003 7:41 pm ]
Post subject: 

Yes...I have heard that Turing isnt exatcly a complex language, from what Catalyst and Home do however Im kind of in shock of what they do with Turing. So, can I ask then how to make Turing draw a box so that I can put in my code that would allow it to move?

code:
    Pic.Draw (leftpaddlepic, x, y, picMerge)
    Input.KeyDown (direction)
    if direction (KEY_CTRL) then
        y := y + 5
    elsif direction (KEY_ALT) then
        y := y - 5
    end if


Right now thats what I have for the movement of the paddles, I have a paddle I drew in paint earlier put in there. I was just wondering how to replace the paddle I drew in paint, with one Turing makes itself.

Author:  Tony [ Tue Nov 25, 2003 7:48 pm ]
Post subject: 

what you do is just redraw the entire screen on top of existing one, this time with paddle moved.

You might want to read up some info on the use of View.Update if you dont want flicker in your animation.

Author:  roer [ Tue Nov 25, 2003 7:50 pm ]
Post subject: 

Thanks tony Smile I'm going to read a bit more about Turing and hope that class teaches me something , my teachers really intresting and informative unlike others I've had

Author:  Andy [ Tue Nov 25, 2003 8:03 pm ]
Post subject: 

have you guys done procedures yet?

Author:  roer [ Tue Nov 25, 2003 8:04 pm ]
Post subject: 

No we havent but I understand the basics of them, do you mind explaining how to link procedures to this because when I tried it came up with an error Embarassed

The debug message was:

procedures may only be declared at the program,module, or monitor level

Author:  Andy [ Tue Nov 25, 2003 8:06 pm ]
Post subject: 

i'd have the whole thing done in procedures.
have a procedure that draw the stuff, and a procedure for movement.

Author:  Tony [ Tue Nov 25, 2003 8:06 pm ]
Post subject: 

a good idea would be to read a tutorial on procedures and such

Author:  AsianSensation [ Tue Nov 25, 2003 8:18 pm ]
Post subject: 

if you tried to declare a procedure in another procedure, then you would get that error.

Author:  roer [ Tue Nov 25, 2003 8:53 pm ]
Post subject: 

code:
var x, y : int := 1
var direction : array char of boolean

procedure leftpaddle
    loop
        Draw.Box (x, y, 100, 100, green)
        Input.KeyDown (direction)
        if direction (KEY_UP_ARROW) then
            y := y + 10
        elsif direction (KEY_DOWN_ARROW) then
            y := y - 10
        end if
        View.Update
        delay (10)
        cls
    end loop
end leftpaddle

leftpaddle


Well, thats what I got with the procedure code so far. The box however is really something, when you press Up or Down the box simply grows. The bottom of the box stays the same however, anyone have any suggestions?

Author:  Andy [ Tue Nov 25, 2003 9:13 pm ]
Post subject: 

your drawing the box from y to 100, you should do from y to y+100 in your draw box thing. o and for collision detection, use whatdotcolor!

Author:  roer [ Tue Nov 25, 2003 9:17 pm ]
Post subject: 

Lol dodge I heard you know a lot about whatdotcolour Smile Care to give me link or short explaination of its function?

Author:  Andy [ Tue Nov 25, 2003 9:22 pm ]
Post subject: 

hey! great idea! tutorial on whatdotcolor! ok i'll give you the short version 1st
whatdotcolor(x,y) gives you an integer which is the color of the pixel at coordinates x,y. for a simple game like pong, your paddle is prolly gonna be all white, so you can simply go around the ball and see if it touches any white ie
code:

for i:-radius..radius
    for j:-radius.. radius
        if i^2+j^2=radius^2 and whatdotcolor(i,j)=white then
            %bounce ball back
        end if
    end for
end for


that will check if the ball had touched any white anywhere.
then basicly, if the ball touches, just switch directions

Author:  roer [ Tue Nov 25, 2003 9:28 pm ]
Post subject: 

whatdotcolour seems to be very practical, is it efficent though? Even if it isn't, it gets the job done it seems Smile thanks for your explaination dodge, i'll use whatdotcolour in my game when I finish it Smile

Author:  Andy [ Tue Nov 25, 2003 9:32 pm ]
Post subject: 

gj my young padawan ha tony take that! Razz
the only thing wrong wtih whatdotcolor is that it is not exactly the most function thing invented... other than that, its very useful... but oh well, in a couple of years, we'll all be runing comps with clock speeds of a couple yodahurtz so who cares about efficency...
i'm gonna invent a language based on whatdotcolor!

Author:  roer [ Tue Nov 25, 2003 9:36 pm ]
Post subject: 

Lol, tony dosen't seem to agree with you on the whatdotcolour topic Rolling Eyes Good luck with that language by the way Wink

Author:  Mazer [ Tue Nov 25, 2003 9:43 pm ]
Post subject: 

dodge_tomahawk wrote:
i'm gonna invent a language based on whatdotcolor!


heck yeah! it'll replace turing as the most taught language in canadian highschools. and then, some kid who sucks at math but excels in compsci will become the greatest in his class and be destined to write the whatdotcolor version of evasive maneuvers.

Author:  roer [ Tue Nov 25, 2003 9:59 pm ]
Post subject: 

One more question....when using procedures how do you display multiple procedures at once? For example, I'm trying to make both of my paddles appear at once using procedures, but it only displays one on the screen. Is there a function that enables both procedures to be operational at the same time?

code:
View.Set ("graphics")
var x, y, x1, y1 : int
var direction, direction1 : array char of boolean
x := 10
y := 10
x1 := 580
y1 := 180
procedure leftpaddle
    loop
        Draw.FillBox (x, y, x + 30, y + 120, green)
        Input.KeyDown (direction)
        if direction (KEY_CTRL) then
            y := y + 10
        elsif direction (KEY_ALT) then
            y := y - 10
        end if
        View.Update
        delay (50)
        cls
    end loop
end leftpaddle

procedure rightpaddle
    loop
        Draw.FillBox (x1, y1, x1 + 30, y1 + 120, blue)
        Input.KeyDown (direction1)
        if direction1 (KEY_UP_ARROW) then
            y := y + 10
        elsif direction1 (KEY_DOWN_ARROW) then
            y := y - 10
        end if
        View.Update
        delay (50)
        cls
    end loop
end rightpaddle

leftpaddle
rightpaddle


Here's the code so far, simple indeed Smile

Author:  Andy [ Tue Nov 25, 2003 10:00 pm ]
Post subject: 

dont have a loop inside the procedure, run both procs in side a loop in your mainline

Author:  roer [ Tue Nov 25, 2003 10:59 pm ]
Post subject: 

Oooooo...I should pay more attention to things like that Embarassed Just finished watching 24 Smile That was an awesome episode BTW Wink

Author:  Tony [ Tue Nov 25, 2003 11:19 pm ]
Post subject: 

roer wrote:
i'll use whatdotcolour in my game when I finish it Smile


that's what happens when I step away from the computer to play some GTA3 Rolling Eyes

Author:  roer [ Tue Nov 25, 2003 11:24 pm ]
Post subject: 

tony wrote:
roer wrote:
i'll use whatdotcolour in my game when I finish it Smile


that's what happens when I step away from the computer to play some GTA3 Rolling Eyes
Embarassed Actually I'm still at debate with myself as to use it or not...your not to late yet Wink

Author:  Tony [ Tue Nov 25, 2003 11:42 pm ]
Post subject: 

dont use the evil!

I'll give you bits Laughing

Author:  roer [ Wed Nov 26, 2003 12:13 am ]
Post subject: 

Lol, bribing me with bits Wink Heh, I'm not using whatdotcolour in my current version of pong...but who knows what the future may holy Wink

Author:  Andy [ Wed Nov 26, 2003 1:12 pm ]
Post subject: 

tony i got a deal for you... heh... you can pay me 100 bits perday to stop corrupting the youngers of compsci.ca with my whatdotcolor... how about it?

Author:  Tony [ Wed Nov 26, 2003 5:14 pm ]
Post subject: 

how about you pay me 50 bits a day (you make way over that will all your spamming) and I dont just take all of them from you with a click of a button? Twisted Evil

Author:  roer [ Wed Nov 26, 2003 5:31 pm ]
Post subject: 

Man..I really caused more strife Wink

Author:  thoughtful [ Wed Nov 26, 2003 6:44 pm ]
Post subject: 

lol they do that all the time, dodge and tony, its the battle for programming superiority Twisted Evil Twisted Evil Twisted Evil . hmm..by the way if you ever get tired of all those bits, i can always take care of em for you Wink Wink

Author:  Andy [ Thu Nov 27, 2003 12:01 pm ]
Post subject: 

lol, yea sry about that.. i just need 2500 bits... i'll stop spamming after that. or you could just give me the rest so i dont have to spam for them

Author:  Dan [ Thu Nov 27, 2003 3:59 pm ]
Post subject: 

Ok this topic has got way of topic.

*Locked*


: