Scrolling tile RPG

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

MilesAway1980
Coder
Posts: 25
Joined: Tue Jul 29, 2008 12:30 pm

Post by MilesAway1980 »

Ralph wrote:One more thing. If PUT works faster then DRAW for the background tile, perhaps you could use PUT for ALL tiles, including the background, and just use DRAW for all the edge tiles? Maybe you already have done this!

I thought that's what you meant originally, so that's what I did. It worked great. :) I PUT all the tiles, and use an ON ERROR statement, so if it errors, it just uses DRAW instead.
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

I guess you are just "miles ahead" of me. :D I thought that up AFTER my post on the DRAW at the edges thing. At that time, I was just thinking you wanted to introduce some new tiles, not those relating to the background or the castle... But, you made the quantum leap from my original thoght, and you PUTed ALL tiles in the "inner" screen, and DRAWed ALL tiles intruding into the edges, which was my last idea. The best part is that you seem to have reported an increase in speed when you did that! That's truly great, as I know that you were concerned with increasing the speed, somehow. Fantastic! Any other "little" problems, ha,ha.

Oh, are you using ON ERROR for EVERY tile you PUT? If so, perhaps there might be an advntage in just swithcing from PUT to DRAW by testing (in SCREEN mode 13) if the y-cordinate is <0>319, or if the x-coordinate is <0> 199?
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
MilesAway1980
Coder
Posts: 25
Joined: Tue Jul 29, 2008 12:30 pm

Post by MilesAway1980 »

Hehe, thanks. :)

Gets me curious though, who thought of the idea? I thought its what you meant in your post, and you didn't actually think of it until after I had already implemented it. Hrm... *scratches head*

Either way, it works great, so I'm very pleased. I'll have to compile a demo of it so everyone can see what it looks like running.

I had also already changed to using the DRAW if it was outside of a certain coordinate (instead of the ON ERROR) because it got rid of a weird graphics streaking thing it was doing occasionally around edges. No speed increase, but it made it look better.

Now that the map is finally all how I want it, its on to just chug coding. So many little things to do so I can finally get the game out. Been way too long!
SlowCoder
Coder
Posts: 26
Joined: Wed Oct 01, 2008 8:27 am

Post by SlowCoder »

I agree that the easiest, and not worst way, would be to GET half tiles. Then, if the coordinate you plan to place a tile at is greater than screen width minus full tile width, place the half tile, instead.

Also, if you don't want to rePUT the entire screen you can create a 2nd array that holds the current tile placement. Then when you need to move your tiles, compare the new values to the old values and replace the ones that are different. Would probably significantly improve efficiency.
Ralph
Veteran
Posts: 148
Joined: Fri Feb 09, 2007 3:10 pm
Location: Katy, Texas

Post by Ralph »

MilesAway1980:

I just saw a copuple of nice program snippets, one for saving an array with a tile by using BSAVE, the other for retrieving the array by using a BLOAD and then PUTing it to screen. That got me thinking of your large program, and your quest for memory. So...Are you into BSAVEing and BLOADing? Can that help you to save some memory? If so, if you have a problem with either command, post back, and I will reply with the example, which is quite complete...well, it may be that we can still improve it a little.
Ralph, with QuickBASIC 4.5, operating under Windows XP, wiht anHP LaserJet 4L Printer. Bilingual in English/Spanish
MilesAway1980
Coder
Posts: 25
Joined: Tue Jul 29, 2008 12:30 pm

Post by MilesAway1980 »

Thanks for the replies.
As it sits right now, I haven't been working much on the map portion of it as it seems to be running really smooth and have been working on other portions of the project.

As for 1/2 tiles, the downside to this is that it doesn't move 10 pixels every time, it moves 1 pixel every time, to give a very smooth scrolling effect. I have to double my tiles and use the DRAW command for tiles that look the same as the array'd ones around the border, but since its only the border, it doesn't slow down very much.

And as for the BLOAD and BSAVE, I've been thinking about that one too, but right now, I'm using BLOAD every time I move the map. This way I can have as many tiles as I want and only one is in memory at any given moment. I think I'll try putting them all in memory at once to see if it speeds things up since, after doing the math, tiles don't take up much memory.
A 20x20 tile is 202 bytes. 202 * 100 tiles = 20200, or 19.7kb. The program usually has around 40 - 50kb and 100 tiles is a lot, so I should be just fine. Especially since that's only when its drawing the map. If it goes into anything else, like fighting or the status screen, all of that is removed, which makes way for that. I'll have to give it a try.



I think I tried it before way back when it was all DRAW statements, but each tile then was around 2KB each (the DRAW tiles are much bigger but they can draw around the borders without crashing), so the same amount of tiles would be 2MB. Yeah, wasn't gonna work. :)
Post Reply