This was done when I was thinking about doing an XPilot type game.
I decided that the complete world would be one sprite, which, whilst making the program very fast, it immediately prevented decent collision detection, especially as the main craft would rotate. You'll need gaphics and the appropriate level DLL to run this.
set display mode 1024,768,32
sync on
sync rate 0
load image "craft.bmp",1,1
load image "fullblock.bmp",2,1
load image "base.bmp",3,1
load image "corner1.bmp",4,1
load image "corner2.bmp",5,1
load image "corner3.bmp",6,1
load image "corner4.bmp",7,1
load image "bullet.bmp",8,1
load dll "TestLevel.DLL",1
width=call dll (1,"?getWidth@@YAKXZ")
height=call dll (1,"?getHeight@@YAKXZ")
create bitmap 1,width*32,height*32
set current bitmap 1
cls 0
for y=0 to height-1
for x=0 to width-1
one=call dll (1,"?readTileAtPosition@@YAKKKK@Z",0,x,y)
if one<>0
paste image 2+(one-1),x*32,y*32,0
endif
next x
next y
get image 2,0,0,(width*32),(height*32),1
set current bitmap 0
`Main Source File
angle#=0
craftX#=100.0
craftY#=100.0
landX#=craftX#-(screen width()>>1)
landY#=craftY#-(screen height()>>1)
bX#=0.0
bY#=0.0
bA#=0.0
bF=0
do
text 0,0,str$(angle#)+" FPS:"+str$(screen fps())+" C:"+str$(one)+" CellX:"+str$(cellX/32)+" CellY:"+str$(cellY/32)
text 0,32," PosX:"+str$(landX#)+" posY:"+str$(landY#)
text 0,64," CraftX:"+str$(cellX)+" "+str$(cellY)
sprite 1,screen width()>>1,screen height()>>1,1:offset sprite 1,sprite width(1)/2,sprite height(1)/2
positionSprite(2,landX#,landY#)
rotate sprite 1,angle#
if leftkey()
angle#=wrapvalue(angle#-1.0)
else
if rightkey()
angle#=wrapvalue(angle#+1.0)
endif
endif
if bF
inc bX#,sin(bA#)*1.0
inc bY#,cos(bA#)*1.0
sprite 3,bX#,bY#,8
dec bF
if bF<=0 then delete sprite 3
endif
if controlkey()
bF=20
bX#=sprite x(1)*1.0
bY#=sprite y(1)*1.0
bA#=wrapvalue((360.0-angle#)+180.0)
endif
if spacekey()
a#=wrapvalue(360-angle#)
tX#=landX#:tY#=landY#
inc landX#,sin(a#)*1.0
inc landY#,cos(a#)*1.0
cellX=((screen width()>>1)-landX#-16.0)
cellY=((screen height()>>1)-landY#-16.0)
text 0,128,str$(cellX)+" "+str$(cellY)
one=call dll(1,"?readTileAtPosition@@YAKKKK@Z",0,cellX/32,cellY/32)
if one=0
inc landX#,sin(a#)*1.0
inc landY#,cos(a#)*1.0
`a#=wrapvalue((360-angle#)+180.0)
dec craftX#,sin(a#)*1.0
dec craftY#,cos(a#)*1.0
else
landX#=tX#
landY#=tY#
endif
`craftX#=landX#-(screen width()>>1)
`craftY#=landY#-(screen height()>>1)
`a#=wrapvalue(360-angle#)
`inc craftX#,sin(a#)*1.0
`inc craftY#,cos(a#)*1.0
endif
sync
loop
function positionSprite(sprNum as DWORD,x# as float,y# as float)
sprite sprNum,x#,y#,2
offset sprite sprNum,0,0
endfunction
The place for all
great plug-ins.
Keep your friends close, and your cats even closer.