Code:
Graphics 800,600,16,2 ;Fenster
tile = LoadAnimImage("gfx\tiles.bmp",32,32,0,8)
char = LoadImage("gfx\spieler.bmp")
px = 1 ;Playerposition x
py = 8 ;Playerposition y
move = 1
Dim map(24,18)
;Legende:
; 0 = Wiese
; 1 = Wasser
; 2 = Brücke
; 3 = Schalter(AUS)
; 4 = Schalter(AN)
; 5 = Weg
; 6 = Wasser für brücke
; 7 = Wall
;Das ist die map:
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,1,1,1,7,7,7,7,7,7,7,7,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,5,5,5,5,5,5,5,5,5
Data 7,5,5,5,5,5,5,5,5,5,5,5,5,6,6,6,5,5,5,5,5,5,5,5,5
Data 7,0,0,0,0,0,0,0,0,0,0,3,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,0,0,0,0,7
Data 7,7,7,7,7,7,7,7,7,7,7,7,7,1,1,1,7,7,7,7,7,7,7,7,7
For y = 0 To 18
For x = 0 To 24
Read map(x,y)
Next
Next
Repeat
SetBuffer BackBuffer()
Cls
If KeyDown(1) Then End ;Escape taste/beenden
For y = 0 To 18
For x = 0 To 24
DrawImage tile,x*32,y*32,map(x,y)
Next
Next
;Hier beginnt die steuerrung:
If KeyDown(208) Then
If Not map(px,py+1) = 1 Or map(px,py+1) = 6 Or map(px,py+1) = 7 Then
Delay(100)
py = py + 1
move = 1
EndIf
EndIf
If KeyDown(200) Then
If Not map(px,py-1) = 1 Or map(px,py-1) = 6 Or map(px,py-1) = 7 Then
Delay(100)
py = py - 1
move = 1
EndIf
EndIf
If KeyDown(203) Then
If Not map(px-1,px) = 1 Or map(px-1,px) = 6 Or map(px-1,px) = 7 Then;Das wird als fehler angezeigt.
Delay(100)
px = px - 1
move = 1
EndIf
EndIf
If KeyDown(205) Then
If Not map(px+1,py) = 1 Or map(px+1,py) = 6 Or map(px+1,py) = 7 Then
Delay(100)
px = px + 1
move = 1
EndIf
EndIf
If move = 1 Then
x = px * 32: y = py * 32:DrawImage char,x,y
EndIf
;Schalter
If KeyHit(57) Then
If map(px,py) = 3 Then
For y = 0 To 18
For x = 0 To 24
If map(x,y) = 6 Then;Brücke wird aktiviert
map(x,y) = 2
EndIf
If map(x,y) = 3 Then;Schalter wird grün
map(x,y) = 4
EndIf
Next
Next
EndIf
EndIf
Flip
Forever