Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 4th Nov 2014 15:24
Hi.

I want make a running game that automatically move Player and view in x direction how can do it?
I wrote this code for move view to x direction that work but I don't know this way is correct or not.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 4th Nov 2014 15:48
It might be better to move the player sprite/skeleton and then position the view based on the player position, that way you can have smooth "camera" movement too.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 4th Nov 2014 16:49
I want say more clear.

I want make a game Like Flappy Bird. mean when press Space key move to up and when don't Press space key, fall to ground. for this work I want move view and Player together to X Direction.
I wrote a code for space key and move player and direction. but don't work good and view don't move with player position.

Please Guide me for make this game.

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Nov 2014 05:24
Can anyone Help Me?
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 5th Nov 2014 13:40
Looks like you are trying to set the View based on the sprites 'x' velocity;

Quote: "SetViewOffset (sprx#,0)"


What you want to do is move the view based on the sprites current position;



This will position the View so that the spr is on the left most edge. If you want to center the sprite then you need to deduct half the screen width;

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Nov 2014 20:00
Thanks Funnell7, good work Now.

Now I need fix space key problem. Problem is that when I Press Space Key my sprite go up with delay and when release space key fall have delay. how can fix this problem? In Floppy Bird game there is no this problem.

Please Guide me to fix this Problem.

Thanks A Lot
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 5th Nov 2014 20:59
I can see you are changing the Gravity when pressing the space key. That isn't really the best way about it... What you want to do is keep the gravity consistent, but then apply velocity to the sprite to keep it in the air...

Something like this;

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Nov 2014 21:19 Edited at: 5th Nov 2014 21:23
Thanks Funnell7. work very well.

for move Player I use this code but seem this way make increase speed. there is any way for Kept constant?


Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 5th Nov 2014 21:32
You are increasing the velocity by 0.1 each cycle which will consistently increase the speed... Instead use a fixed value. For example;

Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 5th Nov 2014 21:38
Thanks Funnell7.

You've helped me a lot.
Funnell7
12
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 5th Nov 2014 22:15
You're welcome

Login to post a reply

Server time is: 2024-05-02 02:45:32
Your offset time is: 2024-05-02 02:45:32