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 / Requesting help understanding the screen scrolling tutorial

Author
Message
EricB
12
Years of Service
User Offline
Joined: 3rd Nov 2011
Location:
Posted: 3rd Nov 2011 18:28 Edited at: 5th Nov 2011 13:23
First thanks for the help in advance.

I have not touched basic since around 1990 as such am really rusty. I have been playing around with the scrolling tutorial and have not been able to do what I want to do.

The effect I am looking for is to have a "map" (topographical) as my background. As the mouse moves over this background I would like my sprite to display a corresponding section of a different image. (photo).

I can create a sprite that shows a singular portion of the photo image but not one that will change as the position of the sprite moves. Perhaps this is not the proper method of doing this procedure?



I appreciate any pointers in the general direction I need to go.

I have concluded that within the confines of DARKbasic it is impossible to define sprite texture coordinates that are outside of the defined sprites initial area.

I have chosen to create the effect I was seeking out of 25 sprites and change which sprite is displayed based on mouse position and key presses.

Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 5th Nov 2011 18:14 Edited at: 5th Nov 2011 18:15
To make it easier you may want to check out the CREATE ANIMATED SPRITE command to create a single image for those 25 sprites. To display them just use the SET SPRITE FRAME command to switch the image used on the sprite.

EricB
12
Years of Service
User Offline
Joined: 3rd Nov 2011
Location:
Posted: 6th Nov 2011 01:04
I had been having problems with the CREATE ANIMATED SPRITE which led me to the above solution.



This uses the 4 x 4 gird of the asteroid supplied with the sprite example bundled with DBP. I can't see where the error is in the above example to simply play the sprite's frames. Perhaps it's simply my not understanding of how to load and play sprites but I'm not seeing it at all.
Grog Grueslayer
Valued Member
18
Years of Service
User Offline
Joined: 30th May 2005
Playing: Green Hell
Posted: 6th Nov 2011 06:51 Edited at: 6th Nov 2011 06:53
You're going to kick yourself... but you forgot the "m" in the filename.

It's "animspr.bmp" not "anispr.bmp".

But it's better to use a .png instead because they allow us to use transparencies (attached is .png version).



You got the right concept though 4 frames across 4 frames down. The image number 16 is not the total images it would make but just a single image number to store all the frames. You're using PLAY SPRITE perfectly.

Attachments

Login to view attachments
EricB
12
Years of Service
User Offline
Joined: 3rd Nov 2011
Location:
Posted: 6th Nov 2011 13:48
Quote: "You're going to kick yourself... but you forgot the "m" in the filename.
"


I looked at that code for an hour and did not see that. Well time to get my boots on it seems I need a good kick.
EricB
12
Years of Service
User Offline
Joined: 3rd Nov 2011
Location:
Posted: 7th Nov 2011 13:33
Now I'm ready to just bash my computer with a large mallet.

I seem to have found some strange pathing / temp file bug.

I open one simple DBPro file


compile and run the code (works fine). I close this project and open and open a new one



next I open a new test
When I compile and run this code the last project I had open is what actually compiles. When I close and reopen the IDE and attempt to compile anything it will crash with strange errors like sprite number must be greater than 0 at line 95 . If I choose "compile in step through mode" I'll get to the last line of my program and then it will jump to line 95 (which is not in my program) and I'll see a section of code from a previous project I had open.

I run Windows Vista on this machine and have UAC disabled and run DARKBasicPro as administrator.
nonZero
12
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 8th Nov 2011 08:48 Edited at: 8th Nov 2011 08:48
Quote: " I seem to have found some strange pathing / temp file bug "


I think it's to do with the fact that you are running an included code file and it is somehow "linked" to your main source. I don't really use included files in DBPRO so this is just a hypothesis. Try completely restarting DBPRO completely and this time select "open source file" from the file menu. It'll give you some crap about current project won't be saved, are you sure, choose yes. Then it will ask you to make a project file for this source, choose no. Then try to compile and run it.

EricB
12
Years of Service
User Offline
Joined: 3rd Nov 2011
Location:
Posted: 8th Nov 2011 12:57
Thanks nonZero,

That solved the problem. I'm not sure how the got into some of my projects but changing the header to main source the problem has gone away. I'm not sure why the file was included if it was not explicitly listed in the include section of my main source file though.
EricB
12
Years of Service
User Offline
Joined: 3rd Nov 2011
Location:
Posted: 9th Nov 2011 00:02 Edited at: 9th Nov 2011 13:01
Back again for more questions. How does the pointer transverse a multi-dimensional array? I have code that splits a (hidden) background screen up into frames of a animated sprite. Next I choose which frame to display based on mouse position. I use an array as part of my solution to determine what frame to display. If I move the mouse slowly I can see each frame between the (x.y) position of the array and the (x+3.y+1) position of the array. I'd like to eliminate that if possible.
Now I'm not asking to have this rewritten just wondering if there is a different method of attacking this problem.

<edit I found a second edge case which would return bad frame numbers

Login to post a reply

Server time is: 2024-05-20 07:45:57
Your offset time is: 2024-05-20 07:45:57