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 / Sprites

Author
Message
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 16th Mar 2011 05:21
Okay i wanna know if there is a better way to make a lot of sprites i dont want to keep writing dbSprite(1,0,0,1); dbSprite(2,0,0,1); over and over for every sprite and i dont want to stretch a sprite im making 2d platform and this would be like the platform that you run on.
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 16th Mar 2011 06:04
Yes, there is definitely a better way to do that.

I would assume that you have a bunch of platform sprites and a character sprite.
you will need an array for your platforms. Make it a generous length so that you will never have more sprites loaded than members in the array.

float plat[200]={0};//0-199
each member will hold the object number of a platform sprite.

You will want to loop through this array when calling collision checks or when drawing.

However, you do not know that the whole array is filled.
Also, considering that you may be loading and unloading sprites, you should record the lower and upper bounds of the used members in your array.
float startplat=0;
float endplat=0;
When you loop through the array check to make sure that the counter is not exceeding 199. If it is set it back to 0.

if(counter>199){
counter=0;
}
sprite(plat[counter],dbSpriteX(plat[counter]),dbSpriteY(plat[counter]),dbSpriteImage(plat[counter])); //example of what you could be doing?

to be continued.

in the mean time look at http://www.thegamecreators.com/?m=codebase_view_code&i=79484a99604e496adca2bd89047ad8a0
be sure to sowload and use the files in the zip except for sprite.bmp. you can replace that.

Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 16th Mar 2011 20:12
Well that gets me somewhere but i have no idea where to place these things and what am i supposed to do with this

im srry im asking so many questions but this would be my very first platformer i just need a lot of help and exact step by step instructions.
Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 17th Mar 2011 00:16
Any one ????????
i really want to get this so can some one explain this step by step
Hawkblood
14
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 18th Mar 2011 12:27
Quote: "sprite(plat[counter],dbSpriteX(plat[counter]),dbSpriteY(plat[counter]),dbSpriteImage(plat[counter]));"

This is the constructor for the sprite. The correct declaration would be:
dbSprite(plat[counter],where you want it X,where you want it Y,image);
This will create the sprite and place it on the screen at the X,Y using the image. You should read the help file concerning sprites. There are many commands that can help you get the result you are looking for.

The fastest code is the code never written.
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 18th Mar 2011 18:28
Sorry, I had a busy week.

I am working on a clear demo but it is not working quite right.

However, this one works.

http://www.thegamecreators.com/?m=codebase_view_code&i=ef928d0fa4438e1969cda377d1992907

Look at how the asteroids and shots are handled.

Oster200
13
Years of Service
User Offline
Joined: 21st Jan 2011
Location:
Posted: 18th Mar 2011 23:01 Edited at: 18th Mar 2011 23:40
okay um there is no errors but i cant see a sprite i dont know if you really want to take time to look at this but this is what i got

main.cpp


player.h
DeadTomGC
13
Years of Service
User Offline
Joined: 11th Aug 2010
Location: LU
Posted: 24th Mar 2011 18:29 Edited at: 24th Mar 2011 18:38
Ok, Here is the sample program. I should probably clean it up a bit, but here it is for now.
main.cpp:

methjump.h:


I had a bug for a while where I thought that the blocks would stop being generated, but instead they were being placed off the screen.

The text in the corner of the screen tells you how many blocks you have made.

Oh, and it has a side scroller.

Edit:
Here is a small alteration of makeblock that causes the objects to be generated in random locations.


Login to post a reply

Server time is: 2024-04-25 05:52:01
Your offset time is: 2024-04-25 05:52:01