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 / Scrolling in 2d

Author
Message
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 17th Oct 2003 02:29
Looking for some advice please.

I am doing a 2d strategic map for a turn based strategy game.

I cant seem to find the right combination for the background(ie map), mainly that I cant scroll over the whole map.

I tried using a large bitmap as the backdrop and using a large sprite as the backdrop but cant get the right combination to work.

By using a sprite I was unable to get printed text messages to show on the map and could not get scrolling anyway.

With a bitmap background, I was able to set up a message box where my turn counter was and simply pasted a new image there each turn and the counter and messages for that turn showed up fine but again, I cant get to scroll around the map which is basically 2 X 2 of the screen display area.

I tried all the camera commands in the examples and tried various things like getting new image area (which caused the game to crash) but cant get the right combination.

The code I am currently using is attached. I can do everything I want but scroll round the full bitmap.

Appreciate some help.
KNau
21
Years of Service
User Offline
Joined: 25th Nov 2002
Location: Canada
Posted: 17th Oct 2003 03:32
This is a test I did to create a scrolling map as a texture for a 3D planar object. If your game is in 2D then just ignore the 3D plane and texturing commands.

Basically I'm loading a 512x512 map image into memory and grabbing a 128x128 area to scroll and display. Since there are no attachments on this forum (that I can see) you will have to provide your own "testmap.bmp" file. The code is has some comments, let me know if you need more help. Use the arrow keys to scroll the map.

http://www.canceriannewmedia.com
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 17th Oct 2003 09:34
Thanks very much KNau.

I am now giving it a try.

Will let you know how it goes.Thanks again.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 17th Oct 2003 12:41
I substituted my own background and after some fidling, got the map to scroll ok. However, because I started with a large image and the commands were set up for something smaller, my map became blurred as I shrank it to fit. A problem that could be solved with a bit of work in paint shop pro.

However, I was using sprites for the bases, task forces and air strikes because the sprite collision function makes it easy to determine contact. Even worked out how to make the image outline bigger (though concealed by the transparency)to simulate search ranges.

The problem now is the sprites move with the scrolling screen, dont remain in place. Their position are co-ordinates on the visible screen. I suppose it would be possible to duplicate the move map functions with an opposite one for the sprites so they would remain in place but this seems to be getting messy, there would be about 30 plus sprites in play at any one time. Will give it a go anyway.

Any other contributions would be welcome.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 17th Oct 2003 12:42
And thnaks for the help so far
IanM
Retired Moderator
22
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 17th Oct 2003 15:21
If you are using DBPro, then check out the tiled scrolling thing in CodeBase
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 17th Oct 2003 18:25
Thanks IanM.

Thanks, I am using DB Pro.

I had already tried that code and I get an error which is the subject of an email to the DBPRO support people to try to find what is the problem(I tried to find a contact for you direct but couldnt at the time). This is because I have downloaded three separate peices of code from diferent sources including this one which return the same type of error for the same line of program. Have not had a response to the email yet (must be overdue by now)

When I execute the code I get error
"array size value must be numeric at line 21"
Line 21 says "BuildSpriteImage()" but I believe that the error actually refers to line 24
"global dim TileMap(GRID_WIDTH-1, GRID_HEIGHT-1) as integer".

I got the same error on the other two peices of code, in one case it also did not return the right line number but in the last case it did return the right line number and it was almost identical to line 24 above.

As a newbie and still learning, don't know enough about it to debug myself. However, I did email one of the other code authors who said he could not understand why it failed and wondered if it was either a bug or if my program does not have the latest updates. (Bought DBPRO less than 2 months ago but will download the update soon and check).

In the meantime would love to use the code but cant for the time being.

Thanks for the advice.

I have several experimental campaign maps at the moment. I made a large one with a bitmap but it lack the feel because the details is small but everything works. I have another version with a bitmap which is good but cant move around 3/4 of the map.

I made one based on KNau's code and I can scroll round but the sprites also move and I think it would be too messy to try and relocate all the sprites every time you scroll the map.

Will keep trying and hope something works out or someone can help.

Thanks for the help.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 17th Oct 2003 19:04
Hooooooooooooold the bus

I debugged it Yahoo!!!!!

Observation, DBPro appears not to like the use of "_" in names. I noticed that all three programs used "_" in the name of the arrays so I tried changing line 24 from
"global dim TileMap(GRID_WIDTH-1, GRID_HEIGHT-1) as integer"to
"global dim TileMap(40,40)"
And it got past there before it crashed.

It then did know what "TILE_WIDTH" was so I went through and changed all values where "_" was used in the name to the actual value eg,64,and it got past that error.

Finally it crashed on the get image commands and I noticed by comparing to the book there was an extra ",1" at the end of the get image commands so I deleted those and hey presto, it works

Not bad considering its 1am here and I have ben in the sherry, hic!

OK, so now to see what a sprite does on that background.
stankarp
20
Years of Service
User Offline
Joined: 2nd Oct 2003
Location: Australia
Posted: 17th Oct 2003 19:13
Thought, does it get the use of "_" confused with labels?

Must stay outa the sherry.

Login to post a reply

Server time is: 2024-09-21 06:48:07
Your offset time is: 2024-09-21 06:48:07