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.

2D All the way! / 2d Sprite movement

Author
Message
Corbula
15
Years of Service
User Offline
Joined: 4th Dec 2008
Location:
Posted: 4th Dec 2008 19:29
Ok so im trying to make a 2d shooter game. And i thought a good place to start was with character movements. So i have found a sprite sheet with various pictures for movement and attacks. But what i want is for it to look like he is moving in the direction as the arrow key im pressing.

Here is some code i have pulled from various places, but need some help refining it.



P.S. im using dark basic pro, but it needs to work in dark basic, are there any differences in the way the code is written?
Corbula
15
Years of Service
User Offline
Joined: 4th Dec 2008
Location:
Posted: 4th Dec 2008 19:47
Also because you have to use bmp files and you can't save them with a transparent background, is there a way to more precisely select the sprite from the image so you dont get a white box around them?
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 6th Dec 2008 00:56 Edited at: 6th Dec 2008 00:57
There's an easier way to do this: look at CREATE ANIMATED SPRITE.

To make the character run the right way, you need to count the frames of the animation and write down which ones go to which movement, then do something like this (pseudocode):

Note: Dir is just a variable that helps tell the program if the character has been running in the same direction for a while or just switched to that direction.




For your transparency problem, try SET IMAGE COLORKEY. Or, you can save the image as a PNG to keep transparency.

Corbula
15
Years of Service
User Offline
Joined: 4th Dec 2008
Location:
Posted: 6th Dec 2008 14:18
Quote: "There's an easier way to do this: look at CREATE ANIMATED SPRITE."


Are you talking about the function CREATE ANIMATED SPRITE?

I heard that only works in DBpro, i need it to work in DB classic. But im using DBPro at the moment.
BMacZero
18
Years of Service
User Offline
Joined: 30th Dec 2005
Location: E:/ NA / USA
Posted: 6th Dec 2008 16:50
Oh, ok. I don't know much about the differences between DBC and DBPro, never used DBC.

This idea can still work without animated sprites. You can do basically the same thing, except use the individual images from the spritesheet as frames.

Login to post a reply

Server time is: 2024-05-02 18:01:33
Your offset time is: 2024-05-02 18:01:33