Was trying to make a physics highmap , and ended up with this.
Video is flickering because of the grapper software. Is there any software that can grap without flickering ?
It looks really cool when everything runs smoothly, and it do even on mobile devices.
Things i learned from this:
1. music mp3 loops: cut off the last 1 sec. of the mp3 and save it as a wav, then 1 sec. before the mp3 ends, you start the 1 sec wav using playsound (playsound is really fast) , and just after you start playsound you stop the mp3 and start it again using playmusic.
it takes around 1 sec. before the playmusic starts so you have a perfect loop, the wav is playing while the mp3 loads.
Actually you need to cut off small parts of the 1 sec. wav to get it 100% correct but its possible.
Im nearly there in this video on the main menu, listen around 48 sec into the video to hear the looping.
2. When using SetViewOffset, it will flicker on some mobile/tablet devices, i found that if i use SetSyncRate( 62, 0 ) on mobile devices, the flicker nearly stops.
( sure your code should be fast enoff to process 60 fps. ) i do not know why, when you do some timer testing you see that the waiting in Swap() for the sync 60 is working,
but perhaps it miss a sync now and then, looks like around every 200-500 sync.
Perhaps swap returns faster when the device forces a max 60 fps ?
( when running in windows it must be set to 60 fps. )
3. SetWindowSize , depending of your game , sometimes you get a mush better fps when you make the screen size larger. give it a try , think this has to do with how many
objects on the screen overlap, so making the screen larger could make less objects overlap.
4. The physics highmap: everything in the video is random generated, so endless landscapes/levels. Its done like this:
Only one tile is used to make all the hills.
for a = 0 to 999999
road[a] = sin.... random ...
next a
...
changelength = wide of the tile you use, i use a 200x200.
...
for a = 0 to (changelength) step 1
roadimg[a] = CopyImage( roadimage, a, 0, 2, 200 )
next a
...
drawroad posx# = view offset , roadstep = graphics quality, i use 2 for high and 4 for low graphics setting (for old slow mobile devices):
for a = 0 to screenwidth step roadstep
...
SetSpritePosition(roadsprites[a],a+(posx#)-roadstep,road[ a+px ]+posy#+(screenheight-250)+graphicsaddx)
imagetouse = FMod( a+posx#, changelength-roadstep)
SetSpriteImage(roadsprites[a],roadimg[ imagetouse ] )
next a
....
I tried everything and SetSpriteImage is the fastest way to make the road follow the viewoffset.
Thats it, should give you an idea of how to make the terrain. you can use the roadsprites with physics on screen , and the road[..] highmap off screen.
...
The game only has one control ( anywhere on the screen) and thats jump, but its really hard/addicting, nearly done, perhaps its released tomorrow.
Hope you can use some of the things i learned, so you dont have to spent the extra hours
Flickering video:
best regards Preben Eriksen,