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! / Help with Sprites

Author
Message
Chris Fodge
18
Years of Service
User Offline
Joined: 31st Aug 2006
Location: New Jersey
Posted: 31st Aug 2006 17:16
Ok... I'm brand new to DBP and am having some problems. I have read "The Beginers Guild to DB" and have a general understanding of basic commands used in the language but i cant seem to get sprites on the screen. I made a small image of a space ship to try out. heres the code that i used (got it right from the book)



I just get a blank sceen. Thanks for any help
Richard Davey
Retired Moderator
23
Years of Service
User Offline
Joined: 30th Apr 2002
Location: On the Jupiter Probe
Posted: 31st Aug 2006 21:50
When you do 'LOAD BITMAP' it sets the current display to that bitmap. So in your case, display 1. Display 0 is the actual screen (i.e. what you can see).

You've two choices:

1) Put this command after your 'get image' call: set current bitmap 0

or

2) Don't use 'load bitmap'. Instead just use 'load image' and then you don't need to use 'get image' at all. Just load + sprite.

"Bite my shiny metal ass" - Bender, Futurama
No pixels were harmed in the making of this post
"Don't ping my cheese with your bandwidth"
Chris Fodge
18
Years of Service
User Offline
Joined: 31st Aug 2006
Location: New Jersey
Posted: 1st Sep 2006 06:18
thanks! i got the sprite loaded and can move it around on the screen like i wish but i have one problem with it... if it moves to the right or left it can go off the screen and i cant figure out how to make it stop at the edge ... heres my code



Thanks
Cave Man
18
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 1st Sep 2006 18:05 Edited at: 1st Sep 2006 18:08
Your doing good for someone who just started.
For not going off the screen use the bigger and smaller operators ("<" and ">")
i changed your code so it wont go off the screen



That should work.


Language: DBP
Chris Fodge
18
Years of Service
User Offline
Joined: 31st Aug 2006
Location: New Jersey
Posted: 1st Sep 2006 19:26
Thanks! that works great! i think next im going to try to set it up so when you press space bar the ship fires but not quite sure how yet
Cave Man
18
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 2nd Sep 2006 00:42
This is what i would do, make an array using a UDT that has x, y, and angle, then make a laser sprite and hide it, then loop through the array and draw all the stuff.
If you don't understand arrays then there's an array on tutorials here http://forum.thegamecreators.com/?m=forum_view&t=84908&b=7

theres also a bunch of other tutorials here http://members.thegamecreators.com/tutorialcity/html/darkbasic_professional.html

and here's a simple little shooting thing

t uses an array instead of a sprite for each bullet. this increases speed.
It's a little long, but you should be able to apply to your code.


Language: DBP
Chris Fodge
18
Years of Service
User Offline
Joined: 31st Aug 2006
Location: New Jersey
Posted: 2nd Sep 2006 06:03
ok... i tried to do that with my program but im not sure i understand everything that i did (a small amount of copy and past).

Before i read your post i figured out how to fire a missle from the ship... i only want one missle on the screen at once so i got it to work well... then i tried to do the same thing with a laser but i want more than 1 on the screen at once... so i tried the array for that... heres the problem....

When the program starts and i want to fire a missle it works fine... then when i want to fire the laser i get problems

first problem is that it is not the image of the laser that i drew it is the image of the missle

second it fires off to the right and i want it to go up... heres the code that i used



thanks in advance
Cave Man
18
Years of Service
User Offline
Joined: 22nd Aug 2006
Location: North Carolina, US
Posted: 2nd Sep 2006 16:19 Edited at: 3rd Sep 2006 01:55
Do you understand the code you put in your program?
i'll comment it extra so you can understand

Here's the code we're looking at.

Do you understand it yet?

The Function were you went wrong is "FireMissle"
you should not load media there

I'm sorry. Maybe this is a bit too advanced.

maybe you should try changing it so you have a sprite for each bullet or missle

You shouldn't use code in your program that you don't understand.


Language: DBP 6.2
Cream cheese is your enemy. Sweet tea is your freind.

Login to post a reply

Server time is: 2025-05-15 05:00:56
Your offset time is: 2025-05-15 05:00:56