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.

DarkBASIC Discussion / Tile pasting

Author
Message
t10dimensional
11
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 2nd Sep 2011 08:59 Edited at: 2nd Sep 2011 09:15
Is there a faster way to do this:



Mostly this part:



This is mostly experimental but kinda forgot if you can use memblocks and have tried to do it by drawing to off-screen bitmap but seems to be the same speed. I'm getting 210fps so no problems this way.


If I always made the right decision the first time, I wouldn't have changed my name from razerx.
BN2 Productions
16
Years of Service
User Offline
Joined: 22nd Jan 2004
Location:
Posted: 3rd Sep 2011 10:56
You could use an off screen bitmap and only make changes to it (basically you don't completely refresh it like that). Perhaps have a button that will run through the entire process to update it or have it on a timer (since essentially nothing changes most of the time).

Just some ideas.

Great Quote:
"Time...LINE??? Time isn't made out of lines...it is made out of circles. That is why clocks are round!" -Caboose
t10dimensional
11
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 4th Sep 2011 02:32
Tried two versions of off screen bitmapping. One drops the speed majorly and the other is bout the same.

Got a update of it. Having where it only updates when moving would be efficient but i could see a lot of bugs if it were a game.

This is the most versatile tile scrolling mini engine I've done. Still going add to it for fun.




If I always made the right decision the first time, I wouldn't have changed my name from razerx.
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 4th Sep 2011 23:42
Well if the tiles themselves don't change, you could just paste it all into one image and then only have to paste that image to the screen.

theComet

t10dimensional
11
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 5th Sep 2011 06:58 Edited at: 5th Sep 2011 08:06
The map can be bigger than my first draft so wouldn't work so well. I'm almost finished with collision, it works just want to add sliding collision. Once that is done, I'll post a "mess with" version just for the heck.


If I always made the right decision the first time, I wouldn't have changed my name from razerx.
t10dimensional
11
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 6th Sep 2011 09:47 Edited at: 6th Sep 2011 09:53
Mostly done, a few small bugs on the mousex/y editing but as for the tile and collision part of the code there are no bugs I have found. So let me know if there are any problems other than the mousetile x/y return.

Arrow keys to move.

Labeled letters for map var and tile var changing.(T,G for tile cycle)

Left mouse to place and right to erase.




If I always made the right decision the first time, I wouldn't have changed my name from razerx.
Fluffy Rabbit
User Banned
Posted: 6th Sep 2011 21:44
Sorry if this is a stupid question, but this seems to be DarkBASIC Pro, and not DarkBASIC Classic, what with "#constant" and "global dim" and other stuff like that.
t10dimensional
11
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 7th Sep 2011 02:29
Oops meant to put DBC commands only in it but seem to have forgotten what are not hah. I like this board though for the good, detailed help I get. If you have DBP or can convert it check it out.


If I always made the right decision the first time, I wouldn't have changed my name from razerx.
Fluffy Rabbit
User Banned
Posted: 7th Sep 2011 10:35
Quote: "Oops meant to put DBC commands only in it but seem to have forgotten what are not hah. I like this board though for the good, detailed help I get. If you have DBP or can convert it check it out."


I can't, sorry. I agree that this is a great community, but I think you would be very wise to focus on supporting DarkBASIC Classic.

(You know, there is an upgrade from DBC version 1.13 to 1.2 that also seems to work on version 0.0. Maybe you could use that.)
Ashingda 27
12
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 15th Sep 2011 02:21 Edited at: 15th Sep 2011 02:22
I've added some codes into your source. This is the method I use for my 2D scrolling games. It uses an extra bitmap that is slightly larger than the screen being screensize + tilesize*2. So if your screen is 1024x768 and the tilesize is 32, the bitmap will be (1024+32*2)x(768+32*2). The point of this is to redraw the map as little as possible and while scrolling you are just copying from the bitmap to the screen most of the time. Keep in mind this example can still be optimized more.


Here's the modified source I get about 1200~1900 fps rate compared to the 240~260 original. Note: this a DBPro only.
- I've made changes to your display statement changing it to "set display mode 1024,768,32,0,0,0" that turns the vsync off.
- Added a bitmap creation just above your main loop.
- Added changes to your collision and images subroutines.


t10dimensional
11
Years of Service
User Offline
Joined: 22nd Mar 2009
Location: Code Cave, USA
Posted: 21st Sep 2011 07:00 Edited at: 24th Sep 2011 19:11
@Ashingda 27
Sorry for not replying sooner, was house sitting and didn't get on their computer any but to create some tiles for a my non-existent game. I'll defiantly spend time messing with your method to get the best fps.

Here was my current version(going to try to put your method in later)

-----

Everything is customizable, some in-game(speed, display width/height, tile placing variables), while others(such as tile width) can be done in code. Use the mouse to place and remover the different tiles.

note:
that if you lower the "display tile width/height" it will only correctly work on even numbers, I know why this happens(in concept), I just don't see a need in my games for there to be a odd number of tiles displayed. And didn't want it to be much more complicated due to bugs.

also character image and collision variables are separate.(to give a 3d effect)

-----



And this was the naked engine:



I'll update this with your version soon. If you could play around with collision and the scrolling and tell me what you think I would appreciate it. Thanks very much for taking the time to help me out. Going to sleep for now though, excited to update it tomorrow.

Edit:

What do you do about animated tiles using this method? It does give a much better fps, but the only way to animated tiles using a bitmap I can think of is to use memblocks to edit the individual tiles. Else you would need to update the whole display.


If I always made the right decision the first time, I wouldn't have changed my name from razerx.

Login to post a reply

Server time is: 2020-08-15 12:49:59
Your offset time is: 2020-08-15 12:49:59