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! / Sprite movement

Author
Message
Epsilon
22
Years of Service
User Offline
Joined: 30th Jul 2003
Location: North West, UK
Posted: 15th Jul 2005 02:09
Hi,

Im new, how would i go about cutting up the attached .gif and playing the top row when standing and the bottom row when moving.

I just want to find out how to do it, then i am going to make my own pixel art for the sprites.

Is .gif even the right file format to use?

Thanks for any hlp on this one
BlinkOk
22
Years of Service
User Offline
Joined: 22nd Oct 2003
Location:
Posted: 15th Jul 2005 23:11
i'd have a look at the sprite command if your using DPpro.

P4 2.8Ghz, 2Gb, 128Mb Radeon Pro, Dark Basic PRO
NanoBrain
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 16th Jul 2005 02:17
Epsilon,

You will need to create two sprites for the character. One, which will animate the bottom half of the character, and the other that will animate the top half of the character. Place the sprites on top of eachother.

Of course, you will probably need to edit the image map a bit to do this.


+NanoBrain+
Epsilon
22
Years of Service
User Offline
Joined: 30th Jul 2003
Location: North West, UK
Posted: 18th Jul 2005 22:57
Why is that NanoBrain?

The top row of 5 images is of an animation played when standing, the bottom 5 images are played left to right when the sprite moves.

To do this you need to cut it in half?

I am drawing a pixel art image at the moment, 100 * 100 pixels, i am going to draw about 5 100 * 100 images of a character punching.

Overall it is to make a simple platform game, at the moment i am just trying to get a sprite animation working, i just dont know how.

Game resolution is probably going to be 800*640.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jul 2005 04:56 Edited at: 19th Jul 2005 05:11
I've just barely started working with animated sprites but i'll try to help you.

The first thing I did was change your graphic to .bmp (DBP didn't like .gif) and moved each frame around. Each frame of an animated sprite must be the same size... because Darkbasic uses the resolution of the image to determine how to split it up. I may have not gotten it perfectly aligned but it looks decent when animated. You can easily throw the image into any graphics editing program and move ryu around in the frames till they align exactly right. I also changed the white background to black (for the transparency).

In my own experiments I have noticed that any animated sprite is automatically anti-aliased so I have a second load for the same image to change image 1 to a non-anti-aliased image.

In the code I have "paste image 50,0,0" remed off. I left it there to show (in case you don't know) where you replace the background with an image so you don't get the blue screen.

Here's the code (this will only work in Pro) If you want it in Classic I can change it a bit and post again. The new graphic is attached too.

Hope this helps.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jul 2005 05:04 Edited at: 19th Jul 2005 05:14
Here's a picture with a box for each frame. As I said above Darkbasic does this automatically. The frames are for those of us without a digital brain.

I personally use Paint Shop Pro to do all 2D graphics. It's real easy to use the multi-layered ability to separate the actual character and frame boxes and the background. And its very easy to turn off one layer (such as the box frames) to save the image for use in Darkbasic.
Epsilon
22
Years of Service
User Offline
Joined: 30th Jul 2003
Location: North West, UK
Posted: 19th Jul 2005 07:21
Thanks Grog, this looks great, i will have a read of this and get back to you if i dont understand a section.

Thanks a lot for explaining a few things for me, ive been looking at some of the sticky posts in the 2d forum and its helping me come to grips with some of the changes that arent obvious, like with removing the blue screen.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 19th Jul 2005 11:03 Edited at: 19th Jul 2005 11:05
NP I'll be happy to answer any questions.

Looking at my own code snip I think i'd be better to move the if statements to the top of the do loop... should of done that first. Oh well... part of coding is always trying to make things better.

Epsilon
22
Years of Service
User Offline
Joined: 30th Jul 2003
Location: North West, UK
Posted: 20th Jul 2005 04:46
Hi Grog,

I have commented your code with what i think is what it is doing and also some questions thrown in there. I changed the last function a bit, only because the select wasnt required with there only being 1 case involved, just incase you weren't aware, just taking an opportunity to be helpful as well.

Thanks a lot for your help on this.

Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Jul 2005 07:28 Edited at: 20th Jul 2005 07:30
I made that function so if you wanted to add the ability to move up and down you have the y variable already in the function ready to be used (I wasn't sure what Ryu's movement limits were).

You're right the first sprite command in the function ryu isn't needed because the sprite was already established on the screen (outside of the function). But it's made for multiple uses so if at some point sprite 1 is deleted (dieing character) or whatever when the game is reset sprite 1 will be created again if the sprite isn't replaced before that function is called.

Pasting an image at 0,0 is at the upper left corner of the screen.

At 640x480 the coordinates are like this:

0--------------- 640
|
|
|
|
480

You can use any image you load as a background (or multiple images combined and a: get image 50,0,0,640,480,1).



The standing do loop, loops about 295 times before exiting (at 5000... lower the number and it loops less). It keeps looping until the conditions are met before exiting the loop (in this case if the current timer()is more than the old timer()+5000).

Mipmaps smooth out the pixels so they look good at any distance from the camera (anti-aliasing). Their mainly for 3D texturing (in most 2D games it's a horrible annoyance). I found out yesterday that this is actually a bug and shouldn't automatically anti-alias at all when creating an animated sprite. But until it's fixed loading the same image right after creating an animated one is an easy workaround.

Hope this helps. If you have more questions feel free to ask.
Epsilon
22
Years of Service
User Offline
Joined: 30th Jul 2003
Location: North West, UK
Posted: 20th Jul 2005 10:01 Edited at: 20th Jul 2005 10:02
Ah thats great thanks a lot Grog, yea i understood what anti-aliasing was but not that mipmapping was the same thing, thanks for that.

My bad on the loop exit, that was just me thinking of how long it takes for the sprite animation to finish playing without looking at the fact that the loop doesnt close until it hits timer + 5000.

All very useful stuff, im actually on the road now instead of broken down at the side of it.

My email is Gideon_RavenorAThotmail.com AT as @ though as u know. If u want to talk about 2d games in the future just email me.

I am planning on getting into the classics first, just going to start working on drawing up my main character and making him move about now.

Thanks again.
Grog Grueslayer
Valued Member
21
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 20th Jul 2005 13:40
Np... I'm glad to help.
NanoBrain
21
Years of Service
User Offline
Joined: 20th Jan 2005
Location: Portland, OR
Posted: 21st Jul 2005 15:35
Epsilon,

It has been a bit from then, but I did not quite take a long enough look at your image map, and neither did I understand you as I thought. So, scratch what I have stated, not that you have not.


+NanoBrain+

Login to post a reply

Server time is: 2026-06-12 11:22:38
Your offset time is: 2026-06-12 11:22:38