Hope this helps other newbies like myself.
this is a partial game of an old acorn game that i have converted to darkbasic, things that are missing are multiple levels and monster ai etc.
Program Code Repton.dba
REM *****************************************************************
REM * REPTON *
REM *****************************************************************
REM * AUTHOR: Fizgog DATE: 03rd MAR 2003 *
REM * *
REM *****************************************************************
SET DISPLAY MODE 800,600,16
SET WINDOW ON
HIDE MOUSE
SYNC RATE 60
SYNC ON
GOSUB _Initialise
GOSUB _SetupLevel
REM =================================================================
REM Begin Main Loop
REM -----------------------------------------------------------------
REPEAT
IF SCANCODE()=0 THEN PlayerDir = PWait
IF SCANCODE()=203 THEN PlayerDir = Left
IF SCANCODE()=205 THEN PlayerDir = Right
IF SCANCODE()=200 THEN PlayerDir = Up
IF SCANCODE()=208 THEN PlayerDir = Down
IF SCANCODE()=57 THEN Quit = TRUE
GOSUB _MovePlayer
GOSUB _CheckActions
GOSUB _MoveObjects
REM GOSUB _MoveEmemies
DrawMap(SpriteX-5, SpriteY-5)
DebugMode(SpriteX-5, SpriteY-5)
SYNC : SLEEP Speed
UNTIL Quit=TRUE
END
REM =================================================================
REM Subroutine _Initialise
REM -----------------------------------------------------------------
_Initialise:
FALSE = 0 : TRUE = 1
Speed = 150
Level = 1
Lives = 3
Score = 0
Debug = TRUE
PWait = 0
Left = 1
Right = 2
Up = 3
Down = 4
PlayerDir = 0
Boulder = 1
Diamond = 2
Earth1 = 3
Earth2 = 4
Pill = 5
Skull = 6
Blank = 7
WallBeg = 8
WallCL1 = 13
WallCR1 = 14
WallCL2 = 18
WallCR2 = 19
WallEnd = 21
Bobble = 22
Safe = 23
Jail = 24
Egg = 25
Key = 26
Slime = 27
Bomb = 28
Trans = 29
Crown = 30
Repton = 31
Spark1 = 32
Spark2 = 33
Monst1 = 34
Monst2 = 35
EggCrck = 48
REM Build Animation Sprites
REM Wait Sprite Frames
WaitSize = 4
DIM WaitAnim(WaitSize)
FOR a = 1 TO WaitSize
READ WaitAnim(a)
NEXT a
REM Right Sprite Frames
RightSize = 6
DIM RightAnim(RightSize)
FOR a = 1 TO RightSize
READ RightAnim(a)
NEXT a
REM Left Sprite Frames
LeftSize = 6
DIM LeftAnim(LeftSize)
FOR a = 1 TO LeftSize
READ LeftAnim(a)
NEXT a
REM Up / Down Sprite Frames
UpDownSize = 2
DIM UpDownAnim(UpDownSize)
FOR a = 1 TO UpDownSize
READ UpDownAnim(a)
NEXT a
REM Spark Sprite Frames
SparkSize = 2
DIM Sparkanim(SparkSize)
FOR a = 1 TO SparkSize
READ SparkAnim(a)
NEXT a
REM Monster Sprite Frames
MonsterSize = 2
DIM Monsteranim(MonsterSize)
FOR a = 1 TO MonsterSize
READ MonsterAnim(a)
NEXT a
REM Wait
DATA 36,31,37,31
REM Right
DATA 38,39,40,41,40,39
REM Left
DATA 42,43,44,45,44,43
REM Up/Down
DATA 46,47
REM Spark
DATA 32,33
REM Monster
DATA 34,35
RETURN
REM =================================================================
REM Subroutine _SetupLevel
REM -----------------------------------------------------------------
_SetupLevel:
Frame = 1
Quit = FALSE
EggFall = FALSE
REM Map size 36x32
MapWidth = 36 : MapHeight = 32
DIM Map(MapWidth,MapHeight)
SpriteX = 0 : dx = 0
SpriteY = 0 : dy = 0
LoadMap(MapWidth,MapHeight,"Level.dat")
REM Remove once Function return's player starting position
SpriteX = 13 : SpriteY = 23
dx = 0 : dy = 0
LoadTileSet(64, 64, "tileset.bmp")
DrawMap(SpriteX-5,SpriteY-5)
RETURN
REM =================================================================
REM Subroutine _MovePlayer
REM -----------------------------------------------------------------
_MovePlayer:
INC Frame
SELECT (PlayerDir)
CASE 0 : GOSUB _AnimWait : ENDCASE
CASE 1 : GOSUB _AnimLeft : ENDCASE
CASE 2 : GOSUB _AnimRight : ENDCASE
CASE 3 : GOSUB _AnimUp : ENDCASE
CASE 4 : GOSUB _AnimDown : ENDCASE
ENDSELECT
REM place player sprite on screen
SPRITE 1, 368, 268, SpriteFrame
RETURN
_AnimWait:
IF Frame > WaitSize THEN Frame = 1
SpriteFrame = WaitAnim(Frame)
RETURN
_AnimLeft:
IF Frame > LeftSize THEN Frame = 1
SpriteFrame = LeftAnim(Frame)
dx = -1
RETURN
_AnimRight:
IF Frame > RightSize THEN Frame = 1
SpriteFrame = RightAnim(Frame)
dx = 1
RETURN
_AnimUp:
IF Frame > UpDownSize THEN Frame = 1
SpriteFrame = UpDownAnim(Frame)
dy = -1
RETURN
_AnimDown:
IF Frame > UpDownSize THEN Frame = 1
SpriteFrame = UpDownAnim(Frame)
dy = 1
RETURN
REM =================================================================
REM Subroutine _CheckActions
REM Player Actions
REM -----------------------------------------------------------------
_CheckActions:
REM Grab new object value in front of player
Value = Map(SpriteX+dx, SpriteY+dy)
REM Brick Walls etc.
IF (Value >= WallBeg AND Value Repton
PASTE IMAGE spr, (x*TileW)+ScreenX, (y*TileH)+ScreenY
ENDIF
NEXT x
NEXT y
ENDFUNCTION
REM =================================================================
REM FUNCTION DebugMode
REM
REM Simple Debugger to display Current Screen Array
REM -----------------------------------------------------------------
FUNCTION DebugMode(MapX, MapY)
INK RGB(58, 110, 165), 0
BOX 0, 0, 144, 160
INK RGB(255, 255, 255), 0
SET TEXT SIZE 16
TEXT 24, 0, "DEBUG MODE"
FOR y = 0 TO 8
FOR x = 0 TO 8
spr = Map(x+1+MapX, y+1+MapY)
IF (spr 2222J:8888
88883792288877:8888
888829793:41397:37?779H737877:8888
88882?794:7=88888877:8888
888837737?>29717:494:7927747417:8888
8888717773?>97G7:794:79774737G2:8888
88887G73734?87843?7:7779N:777737771778888
888879212?>7O7G777988;>2373723728888
8888797271?>77?>73?77?>77277773:2117718888
8888293=>737GG37?>727=;77:1131738888
88887979:7=>7?>22?>719224:3423378888
88882929:29:72?888@21?