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.

Dark GDK / Need help in moving the 2D screen and resting/looping sprite position

Author
Message
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 18th Nov 2008 20:58
OK my first problem is that for example, my character has 2 sprites, one for running:

http://img338.imageshack.us/my.php?image=striderrun2ro0.gif

and one for standing:

http://img338.imageshack.us/my.php?image=sfstrider1sa1.gif

Whenever I press the leftKey, the sprtie changes from standing to the running animation ooK, good so far.

but when I let go of the leftKey, the sprite doesn't go back to the standing sprite, instead it just leave a freezing image of the last KeyEvent I pressed for the sprite.

in short is there a way to go:

if (KeyState="no keys pressed")
{
showsprite("the standing postion IDnumber")
}

so I can force it to go back to the standing postion of no key is pressed.

here is the code methode am using to move the character with(am still a noob):



=====================
=====================


my second problem is I want my character to move forward, and While hes moving forward, I want the screen to move with him too, and when he goes back, the screen goes back with him too, so he doesn't go off screen,like the mario 2D games do, including all the images and sprtie on screen, can someone explain it in a simple way, so I don't get lost.

thank you in advance.
Swordsman
16
Years of Service
User Offline
Joined: 12th Nov 2008
Location: Wigan, England
Posted: 19th Nov 2008 17:49 Edited at: 19th Nov 2008 17:51
while(dbRightkey())
{
.....code......
}

That do?

I just answered the other question in a different thread,the technique is called screen scrolling. Look here for some info:

http://www.tofla.iconbar.com/tofla/gfx/mag03/index.htm

or the XNAified:
http://www.xnadevelopment.com/tutorials/scrollinga2dbackground/ScrollingA2DBackground.shtml
yahya
16
Years of Service
User Offline
Joined: 16th Oct 2008
Location:
Posted: 19th Nov 2008 21:15
Thanks for the links they helped ALOT.

but..... the

Quote: "while(dbRightkey())
{
.....code......
}"


ends up letting all my sprtie disspearing from screen :S .
SushiBox
16
Years of Service
User Offline
Joined: 20th Sep 2008
Location: Ohio
Posted: 19th Nov 2008 21:28
First of all, I would consider making an animated strip from your character, and use dbCreateAnimatedSprite.

Then you are going to need to make a boolean expression for which direction your character is facing.

Here is the Player Render stuffs from my code. We just made a class for it, but what your really looking at are the functions here.



Hope this helps.

www.Helios-Online.net

Login to post a reply

Server time is: 2024-11-25 07:53:48
Your offset time is: 2024-11-25 07:53:48