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.

Newcomers DBPro Corner / I can't See my Sprite

Author
Message
DBProUser
13
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 28th Oct 2010 16:54
Hello All Together,

First i have to apologize for my bad english, however, i hope you can help me.

I tried a Codeblock from Joshua R. Smith



But it doesn't work. I have to admit, that i Using my own Bitmaps, but nonetheless, it should work. DBPro is Loading the Background, but it didn't show the sprite (the Rocket i using). Can you tell me, what is going wrong here?

P.S. If i load the Bitmaps individually, Both maps showing up
And if i Change the Current Bitmap to screen as followed



only the Rocket is shown up.

It would be great, if i can solve the problen with your help. Because Programming in DBPro is really fun.
DBProUser
13
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 28th Oct 2010 21:12 Edited at: 28th Oct 2010 21:32
OK, i think i found out myself, altough it is a little bit weird

with following changes it will work



Maybe i am wrong, but it seems DBPro can only draw a sprite in a Loop. It is Confusing that i can't get a Image of the screen, so that i have to use a Number of a New Image, that i don't really need (in this example the Number two for Bitmap 0, the screen that is already activ)

But... it works!

Im really grateful for any better solution, that you can post me.

Till then, bye!
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Oct 2010 21:33
It's not you or DBPro that's wrong here - it's the original piece of code.

When you load a bitmap, that becomes the current bitmap, and all drawing operations take place only on that bitmap until you switch or load another bitmap. If you use 'SET CURRENT BITMAP 0' after the GET IMAGE command, then the sprite will be drawn.

Your alternate code is OK, but your ideas about why you have to draw in a loop are wrong. When you use the SYNC ON command, you are telling DBPro that you will take control of telling it when to draw to the display, hence your SYNC command in a loop.

Here's the fixed code - Untested, but should work:


Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
DBProUser
13
Years of Service
User Offline
Joined: 28th Oct 2010
Location:
Posted: 28th Oct 2010 21:55
@IanM

Thanks a Lot. Your Answer was what i am Looking for.

I tested it and it works how it should be.

@ Mr. Joshua R. Smith

You really confused me

Thanks again IanM
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 28th Oct 2010 23:17
Don't be too hard on the guys that wrote that book - from what I hear, there's a fair amount of code in that book and from what I've seen posted here, only that one issue about sprites.

Basically, they've done a reasonably good job

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 29th Oct 2010 14:32 Edited at: 29th Oct 2010 15:17
wow, i had actually been looking in that same book...because of the same problem.

there is alot of code in the book, and i agree that they did a good job on it; but there have been times i was trying to figure out bitmap, image, and sprite commands and it felt like the book was being deliberately obtuse on the subject. Not with the coding part, but in explaining the how, when, and where's for using the commands.

[EDIT]Just gave it a go but didn't work for me. not exactly doing the same thing as the book.

got a 5x5x2 array for my map. 5,5,1 tell the program what terrain tile to use. 5,5,2 holds numbers used for specials like flipping or mirroring.

trying to make the forest bitmaps in to sprites to just place them over the terrain but i can't get the forest to show up



With this code (the only change i made between my post and this edit was adding 'Set Current Bitmap 0') all i get is a solid blue screen. with out the Set Current Bitmap all the terrain loads but tree's won't show over.

...this did result in a conversation with my dad this morning when he heard me in my room punching myself in the head, yelling 'Where are all my !@#$ trees?'...so yeah, if he didn't think i was druggie before, he probably does now.

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Oct 2010 15:26
What forest? You haven't loaded any images or bitmaps, so you are using a blank bitmap & sprite.

When you've got that sorted, then drop all of the bitmap commands in your main loop - mirror/flip the sprite instead, and paste that. Also remember that two mirrors or two flips give you the original orientation of the sprite, so you need to remember when you are flipped/mirrored and restore the sprite when you are done.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 29th Oct 2010 19:37
Blood hell, all that typing and it disco's on me right as i click 'post message'. ok, first off, sorry for being...me?; i'm almost at 30hr w/o sleep. secondly, should i put this in another thread?

@DBProUser: sorry for stealing your thread dude.

continueing...again.

this isn't the exact same code i posted before, i'v been working on getting bitmaps to alternate in sequence (like the crappy ocean animation in the old 8-bit nintendo games)



so yeah, there's that. if this should be moved else were feel free.

um, was i reading your adive corrently? should i make all the terrain tiles sprites (was working on that for the crap-amation anyways)? or were you trying to show a shorter method of rotation the coast tiles than the *,*,2 array stuff, bitmap 30, stringed IF's i'm currently using?

oh, update, if it helps narrow down why my trees won't show. i can't find a spot any where in my code that a 'Set Current Bitmap 0' won't paint the whole screen blue. it still does the 'wait key' though.

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 29th Oct 2010 20:24 Edited at: 29th Oct 2010 20:26
I'll give you an example.

Ignore the stuff where I create the images for the sprite and populate my 'map' - the important bits are in the loop at the end:


For each cell in the grid:
- Create a sprite.
- Orientate the sprite.
- Paste the sprite.
- Delete the sprite (if you don't, the orientation is left for the next sprite).

See? Absolutely no need for a bitmap at all. Even if you are using a tile-map, I'd suggest loading to a bitmap, using GET IMAGE to grab every tile, then disposing of the bitmap.

[edit]Missed the last part of your question ... the blue background. That's simple to switch off:


Just insert the above code after your SYNC ON.

Utility plug-ins (26-JUL-2010)
I'm applying terms of use that require you to wear a red nose and honk a horn whenever you use the Internet
Anti Human
18
Years of Service
User Offline
Joined: 8th Oct 2005
Location: Good ol\' West Virginia
Posted: 1st Nov 2010 01:22
sweet, i can use set current bitmap 0 without the full screen blue background.

tryin to work my way through the sprite making code. keep getting a error about the sprite not existing at the line with the
-9999,-9999. figure i'm missing something rather important yet small.

Today is a good day, at least compared to tomorrow.
And every day is a good day to die, because then, there is no tomorrow

Login to post a reply

Server time is: 2024-09-28 22:36:09
Your offset time is: 2024-09-28 22:36:09