Smooth tiled scrolling possible ?

BlitzMax Forums/BlitzMax Beginners Area/Smooth tiled scrolling possible ?

hub(Posted 2010) [#1]
Hi !

i've discontinued my project long time ago. i never found a method to code a smooth vertical tiled 32x32 scrolling with bmax for my classic space vertical shooter game.

But today, do you know if somebody coded a bmax project with a nice tiled scrolling ? Just to know if it was possible !

i've stopped the project, in fact just for this design error... Lot of code for nothing !

Thanks !


Jesse(Posted 2010) [#2]
Not really a waste, you can give me the the source code and I bet I can fix it. :)
Don't really know what the problem is but I bet I can find the solution but I need to look at the source code for that to run some tests of course.


hub(Posted 2010) [#3]
you can give me the the source code and I bet I can fix it

This is a huge project and difficult now to extract only the scrolling code. (Full game engine and editor with maxgui, also lot of graphics).

I've already do that :

http://www.blitzbasic.com/Community/posts.php?topic=84277#952979

and here :

http://www.blitzbasic.com/Community/posts.php?topic=71484#811003

so i want only know if somebody coded a bmax project with a nice tiled scrolling here...


Brucey(Posted 2010) [#4]
Smooth vertical scrolling is entirely possible in BlitzMax.


hub(Posted 2010) [#5]
with 32x32 tiles (DirectX and OpenGL) ? Never see here. (except grey alien code, but his code isn't perfect).


ima747(Posted 2010) [#6]
What do you mean by smooth scrolling? How are you using the tile map exactly (backgrounds, animated tiles, etc.)? How is it not smooth (stuttering when you try to scroll, spacing between tiles, etc.)? If you can't share the code can you share a paired down visual example in screen capture movie?

Are you trying to load stuff on the fly to fill the map? are you recycling old tiles, and or old graphics?


Brucey(Posted 2010) [#7]
with 32x32 tiles (DirectX and OpenGL) ? Never see here.

Well, I have a multi-threaded example running here using 256x256 tiles streaming direct from the internet into a disk cache, then being loaded into RAM by FreeImage and displaying when ready. The tiles are map data from openstreetmap, and the mouse scrolling is smooth as you like. No stutter... silky smooth :-)


ImaginaryHuman(Posted 2010) [#8]
What's so difficult about:

For local y:int=0 until height step 32
   For local x:int=0 until width step 32
      drawimage tile[x/32,y/32],x,y
   Next
Next

?


Jesse(Posted 2010) [#9]

What's so difficult about:


there are different factors that affect the smoothness of a game as I have discovered. It is not the same to have a set of tiles and move them around than to have all the bells and whistles of a game in action. Being able to move objects, add and remove memory segments, fill the video buffer and clean it while the garbage collector is trying to do it's thing and while processes are running in the back ground, and the way graphics are loaded are some of the reasons why games stutter. smooth running "Shmups" are not that easy to create. they require a certain level of programming discipline that is not obviously noticeable.
One of the biggest obstacle to deal with are the random access of the garbage collector. while not noticeable at first, as more and more holes are crated in ram by the garbage collector(by creating and removing explosions and bullets etc.), the more randomly longer it will take to allocate memory for in game use and will affect game performance. This is a problem of all languages with an automatic garbage collector. Just about all of this obstacles can be overcome d. the one I found impossible to deal with are the processes running in the back ground as no delta timing or any other timing process can absolutely solve it all of the time and is a problem related to all computer languages.

@hub
BlitzMax might be slightly less efficient at optimizing some code performance than some other computer languages but not enough to be so different that this language can be useless for your game. A rewrite of some of the game processes might be necessary before this problem can be resolved. It might also be as simple as loading the graphics with different flags settings.


_Skully(Posted 2010) [#10]
I have one running with no smoothness problems. Its entirely possible.

Caching particle/sprite type instances will help significantly with any GC issues.


hub(Posted 2010) [#11]

I have one running with no smoothness problems. Its entirely possible.



@skully.
Could i have your sample (.exe if you want) to test it on my computer ?
you can send it at (hubert.bayre@...)


It might also be as simple as loading the graphics with different flags settings

???


_Skully(Posted 2010) [#12]
It might also be as simple as loading the graphics with different flags settings

I assume he refers to the DYNAMICIMAGE|MASKEDIMAGE flags but I'm not sure that would make any difference.

Hub,
I'll see if I get some time to do that for you. Busy night ahead of me though so you might not see it until tomorrrow if I can today.


hub(Posted 2010) [#13]
i'm not sure too that these flags would make big difference...

Many thanks Skully. It's not very urgent. I've also a lot of work this week. (and the project is stopped for one year).


Jesse(Posted 2010) [#14]
they do make a lot of difference when moving a lot of images in and out of use. it may not be noticeable for a few images but for large quantity of images it is quite usefull. It also keeps the frame rate a bit more steady.


hub(Posted 2010) [#15]
i've already do that.


ImaginaryHuman(Posted 2010) [#16]
One way to avoid the garbage collector problem is to try not to keep allocating/freeing stuff. Just preallocate as much stuff as you can, use arrays instead of linked lists, and don't trash stuff when it's no longer needed, ie for a particle/sprite system just mark the sprites as dormant instead of deleting them. And recycle ;-D


ziggy(Posted 2010) [#17]
Using a proper delta timing helps a lot too


hub(Posted 2010) [#18]
it is true that i use a lot of linked list into my game (for enemies movements, bullets, ...).. But this seems not to be the problem.

In game capture :


The game editor :



hub(Posted 2010) [#19]
@skully.
Do you have a scrolling example as you work on your tileset editor ?


_Skully(Posted 2010) [#20]
hub,

I'm currently battling a white texture bug in TileMax so I can't show you anything recent... but I do have the TileMaxPlusEd demo I put out ages ago

run fullscreen2
click the lower window to add atomatons

the other file is the editor..
Its not a great editor but if you run it and do the following:
File - Load
Then click mouse mode to "Move"
click and drag the map

I wish I could give you something more recent.


hub(Posted 2010) [#21]
Thanks for your démo. Have you also a fullscreen exemple ?

My screen resolution is 1440x900 px. I use 1024x768 screen resolution for graphics into my game. On my monitor, I play my game at 1440x900 px using the setvirtualresolution command.


hub(Posted 2010) [#22]
it's all my project with sources and gfx. But huge archive, 37 mo.
- delete all the file inside the 'conf' folder to change resolution settings.
- lauch zigwigwi.exe to try the game.
- There is also the editor and a program transition to add cutt-scenes.

Link here : http://www.bayre.com/2010/zig2010.zip

During game you can press 'g' to god mode. 'd' or 'm' for other infos. 'w' to win the level and pass to another level.

Edit editor.ini and set lang=0 to have english text inside the editor.

This version not finished ! So don't blame me about bugs and strange gfx !


Nate the Great(Posted 2010) [#23]
if you are getting gaps in between your tiles you can set the scale to 1.05 or 1.1 or something unnoticable depending on your game. other than that, I have never seen a problem with tile scrolling in bmax.


Jesse(Posted 2010) [#24]
what the... it's working fine here. moving smooth throughout the whole level. Nothing noticeable visible.
Moves between 62 and 63 fps and very seldom does it go below 62.

my laptop: Intel core 2 duo 2GHz with Intel 945 graphics.

if it works as smooth in your computer as it does here then you'll never be happy. I did change the flip to 1 to avoid tearing other than that it's working perfect as far as movement. I did notice artifacts in the tiles but that has to do with scaling and virtual graphics. I doubt there is a workable solution for that in any language and will be a problem scrolling in any direction. A possible solution would be if there was a way to paste all of the images in an actual size buffer then scale the finished buffer to fit the screen that would be ideal. Other than that, you are out of luck.


hub(Posted 2010) [#25]
Many thanks for your test ! So i can continue to work on this project (lot of gfx to produce and code to debug !) The game force the fps to 60. (There are some delta timing code inside but 'not' activated in this demo. it was too hard to fix problems for me).


hub(Posted 2010) [#26]
I could be interesting for me if someone could try to compile zigwigwi.bmx and editor.bmx on Macintosh or Linux. Just to know if it works also on these OS. i'm just curious about this.


MGE(Posted 2010) [#27]
re: Artifacting, tile gaps, etc, etc. The only solution is to run the game in a resolution that does not stretch or scale the game to the screen. This usually involves picking a resolution = or > to the game's resolution and then centering the game on it.

Another thing I've done in the past, is take your original 32x32 tile map and render to (before each level, etc) larger tiles such as 256x256, etc, etc. This way the gaps/artifacting, etc, are much less visible. If you're doing realtime tile animation it can be tricky because you have to update the 32x32 tile inside the larger tile, but it all can be done.