How can I do this?!
Author |
Message |
Kristiantio
|
Posted: Sat Jan 17, 2009 12:36 pm Post subject: How can I do this?! |
|
|
Im attempting to include a small game for a project due on Monday but i have no idea what im doing...so far i figured this much
Turing: | var chars : array char of boolean
var updown : int := 200
var haha : int := 1
var comp : int := 700
drawfill (1, 1, 53, 53)
drawfilloval (30, 210, 10, 8, 100)
drawfilloval (30, 200, 30, 8, 125)
loop
Input.KeyDown (chars )
%Movement for pressing up arrow
if chars (KEY_UP_ARROW) then
for i : 1 .. 10
updown := updown + 1
drawfilloval (30, updown + 10, 10, 8, 100)
drawfilloval (30, updown, 30, 8, 125)
delay (2)
drawfilloval (30, updown + 10, 30, 14, 53)
drawfilloval (30, updown, 60, 30, 53)
%Collision detection
exit when updown + 17 = 399
end for
%Keeps ship from disapearing when u let go of the key
drawfilloval (30, updown + 10, 10, 8, 100)
drawfilloval (30, updown, 30, 8, 125)
end if
%Movement for pressing dpwn arrow
if chars (KEY_DOWN_ARROW) then
for t : 1 .. 10
updown := updown - 1
drawfilloval (30, updown + 10, 10, 8, 100)
drawfilloval (30, updown, 30, 8, 125)
delay (2)
drawfilloval (30, updown + 10, 30, 14, 53)
drawfilloval (30, updown, 60, 30, 53)
%Collision detection
exit when updown - 8 = 0
end for
end if
%Keeps ship from disapearing when u let go of the key
drawfilloval (30, updown + 10, 10, 8, 100)
drawfilloval (30, updown, 30, 8, 125)
%Collision with wall explosion
if updown + 17 = 399 or updown - 8 = 0 then
loop
haha := haha + 1
delay (20)
drawfilloval (30, updown, haha, haha, red)
delay (20)
drawfilloval (30, updown, haha, haha, yellow)
if haha = 50 then
haha := 50
drawfilloval (30, updown, haha, haha, 53)
end if
exit when haha = 50
end loop
exit
end if
end loop |
I want to have 5 circles appear at a random y coordinate simultaneously 10 times, they will move towards the ship, if the player gets hit he blows up just like when he hits the wall. This should happen 10 times
if the player gets through he succeeds. If i put some new loop in there the ship doesnt move....and i don't know where to start regarding the collision detection between the ship and the incoming circles.
Mod Edit: Remember to use syntax tags! Thanks code: | [syntax="turing"]Code Here[/syntax] |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
The_Bean
|
Posted: Sat Jan 17, 2009 1:38 pm Post subject: Re: How can I do this?! |
|
|
You will need to know arrays and procedures.
Create the enemies, then using a for loop, loop through each one moving them and checking their distance from the ship using Math.Distance().
If the distance between the 2 objects is less than their radius's added together then there is a collision. |
|
|
|
|
|
Kristiantio
|
Posted: Sat Jan 17, 2009 4:19 pm Post subject: RE:How can I do this?! |
|
|
Thank you ill try that. Hopefully i can make it work |
|
|
|
|
|
|
|