hey
I Tested it, I think this is pretty good but its not the best I've seen (no offense). The reason being the resolution is low so the frame rates are good; 150fps (which is very good for me I have a rubbish PC), however if I up the resolution to 800,600,32 (my normal resolution) and double the size of image, so the tiles are double the size (40 by 40 pixels); hence nearly the whole screen is filled; and the framerate is 50fps; not so good.
Two quick ways to improve the speed are put this at the end of the setup code set sprite 1,0,1 then take out the command cls you don't need as your updating the screen with your tiles constantly; I got a 20fps boost in both resolutions which makes it much better.
(Note : I tested this with sync rate 0 to get the maximum fps)
Here is the code
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`» Scrolling Engine »
`» With tile cropping »
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`» By Daniel Fessler »
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`Feel free to use and adapt this engine any way you want, but if you do
`you need to give credit to me somewhere within the program and a link
`to my website; www.calypson.netfirms.com <--soon to be changed, but
`that link will work for now.
`another note: Please do not use my tiles in any games that you make
`(with this engine or not). as for they are only to demonstrate how to
`use the eninge and are copyrighted. Thank You.
gosub setup
`Main loop for ground engine:
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
do
gosub keys
`gosub npcs
`gosub shooting
`gosub hotspots
gosub update
loop
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
keys:
if upkey() = 1
if ydiff > 0 then ydiff = ydiff - speed
endif
if downkey() = 1
if ydiff < (rows*20)-(12*20) then ydiff = ydiff + speed
endif
if leftkey() = 1
if xdiff > 0 then xdiff = xdiff - speed
endif
if rightkey() = 1
if xdiff < (columns*20)-(16*20) then xdiff = xdiff + speed
endif
return
update:
`take out this
`cls
if int(xdiff/20)+1 > 0 and int(xdiff/20)+18 < columns then startx = int(xdiff/20)+1
if int(ydiff/20)+1 > 0 and int(ydiff/20)+14 < rows then starty = int(ydiff/20)+1
for y = starty to starty+14
for x = startx to startx+18
if framer(x,y)>0
show sprite 1
sprite 1,0,0,framer(x,y)
paste sprite 1,(x*20-20)-xdiff,(y*20-20)-ydiff
hide sprite 1
endif
next x
next y
text 0,0,str$(screen fps())+" FPS "
sync
return
`ABOVE: In-Game Coding
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»» Seperator thingy »»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`BELOW: Innitial Setup
setup:
set display mode 320,240,16
sync on : sync rate 130
hide mouse
ink rgb(255,255,255),0
`*******************************
`******** Variables ********
`*******************************
xdiff = 0
ydiff = 0
speed = 1
`*******************************
`******** Variables ********
`*******************************
`load all tileimages (img #50-#60)»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
load bitmap "Jungle tiles.png"
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`seperates each tile into indidual images (img #500-#2000)»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`paste image 50,0,0,1
for y = 1 to 12
for x = 1 to 16
get image (((y-1)*16)+x),x*20-20,y*20-20,x*20,y*20,1
next x
next y
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`Loads the map into memory»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
open to read 1,"demo lvl.map"
read string 1,temp$
columns = val(temp$)
read string 1,temp$
rows = val(temp$)
dim framer(columns,rows)
for x = 1 to columns
read string 1,temp$
for y = 1 to rows
tempmid$ = mid$(temp$,y*3-2)+mid$(temp$,y*3-1)+mid$(temp$,y*3)
framer(x,y) = val(tempmid$)
next y
next x
sprite 1,0,0,1
`input this command
set sprite 1,0,1
`»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
return
Check out IanM's code in the code base as his tile system is good; also I've got a very good system which I'm not willing to share just yet, still doing work on it, also might be using it commercially; currently I can get 75-80fps with a tile size of 20 by 20 pixels and its not optimized yet.
Good luck with this you've done good things with this just needs tweaking
pizzaman