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 / How do I fix this (2d Sprite)

Author
Message
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 25th Jul 2008 19:23
Okay, so I put this whole thing together for practice to get into dark gdk. I got the contra sprites and edited it to only running. But if you ever played a contra game, you would know that the guy runs to the right, but if you make him run to the left, he TURNS AROUND so his gun is facing the other way. So I edited the sprite sheet for him running to the left and right and this is what I came up with:



First off before I show my code, is it possible to put some type of code that flips the sprite around so I won't need to add the extra frames of him running to the left.

Now, here is the problem, You would think that everything would go okay, atleast for me becuase I put it that when he is running to the right to play frames 2 to 8, but when he runs to the left to play frames 10-16. The problem is when I press my LeftKey, he does move in that directioin, but he plays one animation loop running to the left, then he turns around. It is as if for him to turn around and run, gdk goes through frames 2-8 to get to 10-16.

Here is what I have:



The S you see in the beginning of the if statements is to show what side he is facing, 0 is for left and 1 is for right. The reason i did this is so when you shoot, it looks to see what s is equal to to see what side he is facing, and shoots to that direction.

But about the Main problem with him turning around. Is there anyway I can fix that?
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Jul 2008 19:40
dbMirrorSprite ( spriteNum );

That will turn it around.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 25th Jul 2008 19:53
where would i post that exactly?
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 25th Jul 2008 20:09
I suspect that the dbPlaySprite () function requires that a sequence be played out before it will start a new one. You might be able to overcome this by using the dbSetSpriteFrame () function to jump to the first frame of your new sequence (or the last frame of your old one) before calling the dbPlaySprite() with the new sequence.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Jul 2008 20:11
I need to mess with the animated sprite functions more. I know nothing about them.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 25th Jul 2008 20:13
OK, Thanks for the help guys. I really appreciate it The dbMirrorSprite did it but I had to play around with it because it gave me some crazy weird problems with the sprite. When I put it like this, it worked just fine:

Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 25th Jul 2008 20:44
Quote: "The dbMirrorSprite did it but I had to play around with it because it gave me some crazy weird problems with the sprite"


Sometimes you have to keep track if the sprite is already mirrored or flipped and decide if you need to do it again or not.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Jul 2008 20:47
Where did he post that?

Just make a variable to keep track of it. Preferably a bool.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Lilith
16
Years of Service
User Offline
Joined: 12th Feb 2008
Location: Dallas, TX
Posted: 25th Jul 2008 20:53
Quote: "Where did he post that?"


Noob delay. I just copied and pasted from the notification I got in email rather than wait for the post to show up. It'll get here eventually.

Quote: "Just make a variable to keep track of it. Preferably a bool."


That's what I do with my Sprite class. That's because I also provide an UnFlip and UnMirror function. Otherwise, just query the sprite itself. There's a function that lets you know that.

Lilith, Night Butterfly
I'm not a programmer but I play one in the office
Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 25th Jul 2008 21:00
Oh. That makes sense.

Yeah. Just keep track of it with a bool variable or, like Lilith said, you could use the dbSpriteMirrored to find out if it's flipped. I recommend a bool, though.

Windows Vista Home Premium Intel Pentium Dual-Core 1.6 Ghz 1GB DDR2 RAM GeForce 8600GT Twin Turbo
Scope 51791
16
Years of Service
User Offline
Joined: 25th Jul 2008
Location:
Posted: 25th Jul 2008 22:40
Yea, I'll make sure to keep that in mind with the bool.

I was just wondering if there is an easy way to make a sprite jump and come back down. I can't think of anything. Only when you press a button it lowers the value of an integer that is the y axis that will move the sprite up when you put dbSprite ( ID, X, Y, ID ); but how would I then make it come back down normally, as if he jumped only straight up when standing still and jumped up while he was running foward but he went up and foward in the air.

Thanks.

Login to post a reply

Server time is: 2024-11-20 17:44:58
Your offset time is: 2024-11-20 17:44:58