Scrolling Engine Code
Blitz3D Forums/Blitz3D Beginners Area/Scrolling Engine Code
| ||
Anyone have an idea of the best way to load in several 2D game screens (bitmaps) of my game so I can scroll across? I think if defender or other side scrollers, and would like something similar. Thanks Teff |
| ||
I also remembered, a 3D plane, textured with a camera in a top/down view may work. All I would do is 'scroll' the textured plain. Ideas? |
| ||
Or you can use tiles. Try out Mappy to make the maps with. I have made a small test proggy, get it here |
| ||
Well heres a test tile scroller i just made, here ya go, hope it helps:Graphics3D 800,600,16,2 SetBuffer BackBuffer() cam=CreateCamera() PositionEntity cam,64,10,64 RotateEntity cam,90,0,0;turn camera so its pointing straight down,place in middle of field light=CreateLight() RotateEntity light,90,0,0 mapx=128 mapy=128 ;create a terrain terr=CreateTerrain(128) ;create a generic floor tile tile=CreateMesh() surf=CreateSurface(tile) v1=AddVertex(surf,0,0,0,0,0) v2=AddVertex(surf,1,0,1,1,1) v3=AddVertex(surf,1,0,0,1,0) v4=AddVertex(surf,0,0,1,0,1) tri=AddTriangle(surf,v4,v2,v1) tri2=AddTriangle(surf,v2,v3,v1) HideEntity(tile) ;create 1 quick texture texture=CreateTexture(256,256) SetBuffer TextureBuffer(texture) EntityTexture terr,texture SetBuffer TextureBuffer(texture) Color 128,128,128 Rect 28,28,200,200 SetBuffer BackBuffer() Dim m.map(mapx,mapy) ;set each maptile to the texture x=0 While x<mapx For y=1 To 100 Step 1 m(x,y)=New map m(x,y)\mesh=CopyEntity(tile) m(x,y)\image=texture EntityTexture m(x,y)\mesh,m(x,y)\image Next x=x+1 Wend While Not KeyHit(1) If KeyDown(200)=True MoveEntity cam,0,.25,0 If KeyDown(208)=True MoveEntity cam,0,-.25,0 If KeyDown(205)=True MoveEntity cam,.25,0,0 If KeyDown(203)=True MoveEntity cam,-.25,0,0 RenderWorld Flip Wend ClearWorld() End Type map Field mesh Field image Field x Field y End Type Note you could use data statements or your own little data file to read the different map images:like this dim image.image(100) image(1)=loadimage.. image(2)=loadimage... image(3)=loadimage... file=openfile("c:\mapdata.dat") x=0:y=0 while not eof(file) b=readline(file) If x>mapx then y=y+1 and x+0 endif m(x,y)\image=image(b) x=x+1 wend closefile(file) |
| ||
That's good. I think I will attempt something along those lines. Now in a defender type of side scroller, in order to make parallax scrolling, I would just use >1 plain scolled at different speeds right? Or should I just scroll by moving the camera rather? Teff |
| ||
I just added - I could also just make the world out of 3D blocks as shown above and scroll the camera then. I think I will try either way to create something... Teff |