heli won't fall down?

Talk about making games.

heli won't fall down?

Postby refresh » Tue Mar 03, 2009 2:59 am

for key down i put
Code: Select all
x = x +5;
 y = y -3;

that works fine. it rises and moves forward.
then so it falls and moves forward i put into key down
Code: Select all
x = x +5;
y = y +3;

then it dose it for 1 millisecond. how do i repeat it so if im not holding a key it moves forward and falls? :wink:

when i get this right ill give you guy's a demo.
refresh
 
Score: 0 Give a positive score

Re: heli won't fall down?

Postby skydereign » Tue Mar 03, 2009 3:36 am

If I get what you are saying, upon key down, you can set the move right in script by doing this
Code: Select all
xvelocity=5; // sets the velocity, to stop you would need an event that sets it to 0
y-=5; // your rising


In the draw actor event, you should use this for your gravity
Code: Select all
yvelocity+=(whatever value you want gravity); // usually 1 or less, I think
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: heli won't fall down?

Postby refresh » Tue Mar 03, 2009 4:00 am

hey it worked thx again skydereign
my friend :D
refresh
 
Score: 0 Give a positive score

Re: heli won't fall down?

Postby refresh » Tue Mar 03, 2009 4:18 am

key down event
Code: Select all
x = x +5;
y = y -4;


key up event
Code: Select all
xvelocity = xvelocity = +5;
yvelocity = yvelocity +4;


these are my current codes on actor at first it worked then around the third time it shot forward (to the right) with great speed. i was confused so i messed around checked my code but nothing was wrong now what did i do wrong?
Last edited by refresh on Tue Mar 03, 2009 4:31 am, edited 1 time in total.
refresh
 
Score: 0 Give a positive score

Re: heli won't fall down?

Postby refresh » Tue Mar 03, 2009 4:29 am

here's my game you may mess with it and tell me problem. :D :D
comment on beta plz.
refresh
 
Score: 0 Give a positive score

Re: heli won't fall down?

Postby skydereign » Tue Mar 03, 2009 5:16 am

I think this is what you wanted. Upon the keydown you set the xvelocity. Until you change the xvelocity, the actor will continuously move right. Then, since you want the helicopter to rise, do the y+=3. This will make you go up only when pressing up. Then a draw actor script, you put y+=2, to set gravity. For this game you would not use the yvelocity+=, as it is not the proper gravity system. This will make your helicopter fall at all times, rising only when you press up.

As for the game, it is a good start. I don't really know where you are going with it though. At this point you could take it many ways, calculating score by distance, by enemies (if you add them), or some other paths. You might tweak the values, I just set them to relatively fitting values.
Attachments
data.zip
(226.58 KiB) Downloaded 103 times
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron