PDA

View Full Version : Stick Demo



peter
14-05-2013, 13:30
This is a Pseudo 3D demo.
There is not much what you can do, pick up all the brownish sticks.
Perhaps, it gets a game in the future.


#INCLUDE "sdl.inc"
#DEFAULT BOUNDCHECK Off

SDL_Window 640,480,1
Long fo = SDL_LoadFont "stick/font2.ttf",32

Dim Map1(1200) As Byte
Dim Map2(1200) As Byte
Dim Map3(1200) As Byte
Dim Map4(1200) As Byte

Long lev,tiles,ayne,stick,ax,ay,az,ad,ar,count,wx,wy,wz,away,play
Single wv, av
String w1="stick/jubel.wav"
String w2="stick/cans.wav"
lev=1

SDL_LoadBytes "Maps/Map" & Lev & "-1.bin",map1
SDL_LoadBytes "Maps/Map" & Lev & "-2.bin",map2
SDL_LoadBytes "Maps/Map" & Lev & "-3.bin",map3
SDL_LoadBytes "Maps/Map" & Lev & "-4.bin",map4

tiles= SDL_LoadTile "stick/tiles.png",8,3
ayne = SDL_LoadTile "stick/ayne.png",4,4
stick= SDL_LoadImage "stick/stick.png",1
away = SDL_LoadImage "Stick/away.png",8

Sub stickaway()
If wy>0 Then
SDL_Sprite(away,wx,wy,wz)
wv=wv+.2
If wv >=1 Then
wv=0
wz=wz+1
If wz=8 Then
wz=0
wy=0
Endif
Endif
EndIf
End Sub

Sub DrawMap1()
Long x,y,z
For y=0 To 14
For x=0 To 19
z=(y*40+x)+1
If Map1(z)= 1 Then SDL_Tile(tiles,x*32,y*32,1,0)
If Map2(z)= 8 Then SDL_Tile(tiles,x*32,y*32,0,1)
If Map2(z)=16 Then SDL_Tile(tiles,x*32,y*32,0,2)
If Map2(z)=10 Then SDL_Tile(tiles,x*32,y*32,2,1)
If Map2(z)=11 Then SDL_Tile(tiles,x*32,y*32,3,1)
If Map2(z)=13 Then SDL_Tile(tiles,x*32,y*32,5,1)
If Map2(z)=14 Then SDL_Tile(tiles,x*32,y*32,6,1)
If Map2(z)=15 Then SDL_Tile(tiles,x*32,y*32,7,1)
If Map2(z)=21 Then SDL_Tile(tiles,x*32,y*32,5,2)
If Map2(z)=20 Then SDL_Tile(tiles,x*32,y*32,4,2)
If Map2(z)=22 Then SDL_Tile(tiles,x*32,y*32,6,2)
If Map2(z)=23 Then SDL_Tile(tiles,x*32,y*32,7,2)
If Map2(z)=19 Then SDL_Sprite(stick,x*32,y*32,0)
If Map4(z)= 2 Then SDL_Tile(tiles,x*32,y*32,2,0)
If Map4(z)= 3 Then SDL_Tile(tiles,x*32,y*32,3,0)
If Map4(z)= 6 Then SDL_Tile(tiles,x*32,y*32,6,0)
If Map4(z)= 7 Then SDL_Tile(tiles,x*32,y*32,7,0)
If Map4(z)= 4 Then SDL_Tile(tiles,x*32,y*32,4,0)
If Map4(z)=12 Then SDL_Tile(tiles,x*32,y*32,4,1)
If Map4(z)=13 Then SDL_Tile(tiles,x*32,y*32,5,1)
If Map4(z)= 5 Then SDL_Tile(tiles,x*32,y*32,5,0)
Next
Next
End Sub

Sub DrawMap2()
Long x,y,z
For y=0 To 14
For x=0 To 19
z=(y*40+x)+1
If Map4(z)= 2 Then SDL_Tile(tiles,x*32,y*32,2,0)
If Map4(z)= 3 Then SDL_Tile(tiles,x*32,y*32,3,0)
If Map4(z)= 6 Then SDL_Tile(tiles,x*32,y*32,6,0)
If Map4(z)= 7 Then SDL_Tile(tiles,x*32,y*32,7,0)
If Map4(z)= 4 Then SDL_Tile(tiles,x*32,y*32,4,0)
If Map4(z)=12 Then SDL_Tile(tiles,x*32,y*32,4,1)
If Map4(z)=13 Then SDL_Tile(tiles,x*32,y*32,5,1)
If Map4(z)= 5 Then SDL_Tile(tiles,x*32,y*32,5,0)
Next
Next
End Sub

Sub FindAyne()
Long x,y,z
For y=0 To 14
For x=0 To 19
z=(y*40+x)+1
If Map3(z)=72 Then
ax=x*32
ay=y*32
Endif
If Map2(z)=19 Then
count=count+1
Endif
Next
Next
End Sub

Sub SetAyneValues()
av=av+.2
If av >=1 Then
av=0
az=az+1
If az=4 Then az=0
Endif
ar=ar+2
If ar=32 Then ar=0
End Sub

Sub RunAyne()
If ad=0 Then
SDL_Tile(ayne,ax,ay,1,0)
ElseIf ad=1 Then
ax=ax+2
SDL_Tile(ayne,ax,ay,az,3)
SetAyneValues()
ElseIf ad=2 Then
ax=ax-2
SDL_Tile(ayne,ax,ay,az,2)
SetAyneValues()
ElseIf ad=3 Then
ay=ay-2
SDL_Tile(ayne,ax,ay,az,1)
SetAyneValues()
ElseIf ad=4 Then
ay=ay+2
SDL_Tile(ayne,ax,ay,az,0)
SetAyneValues()
Endif
End Sub

Sub ScanAyne()
If ar > 0 Then Exit Sub
Long x,y,s
x=ax/32
y=ay/32
s=(y*40+x)+1
If SDL_Key(275) And Map3(s)=72 And Map2(s+1)=19 Then
Map2(s+1)=0
Map3(s)=0
Map3(s+1)=72
wx=ax+32
wy=ay
count=count-1
PlayWav w2,0,1
ad=1
ElseIf SDL_Key(276) And Map3(s)=72 And Map2(s-1)=19 Then
Map2(s-1)=0
Map3(s)=0
Map3(s-1)=72
wx=ax-32
wy=ay
count=count-1
PlayWav w2,0,1
ad=2
ElseIf SDL_Key(273) And Map3(s)=72 And Map2(s-40)=19 Then
Map2(s-40)=0
Map3(s)=0
Map3(s-40)=72
wx=ax
wy=ay-32
count=count-1
PlayWav w2,0,1
ad=3
ElseIf SDL_Key(274) And Map3(s)=72 And Map2(s+40)=19 Then
Map2(s+40)=0
Map3(s)=0
Map3(s+40)=72
wx=ax
wy=ay+32
count=count-1
PlayWav w2,0,1
ad=4
ElseIf SDL_Key(275) And Map3(s)=72 And Map3(s+1)=0 Then
Map3(s)=0
Map3(s+1)=72
ad=1
ElseIf SDL_Key(276) And Map3(s)=72 And Map3(s-1)=0 Then
Map3(s)=0
Map3(s-1)=72
ad=2
ElseIf SDL_Key(273) And Map3(s)=72 And Map3(s-40)=0 And Map4(s-40)=0 Then
Map3(s)=0
Map3(s-40)=72
ad=3
ElseIf SDL_Key(274) And Map3(s)=72 And Map3(s+40)=0 And Map2(s+40)=0 Then
Map3(s)=0
Map3(s+40)=72
ad=4
Else
ad=0
Endif
End Sub

FindAyne
While SDL_Key(27)=0
DrawMap1
ScanAyne
RunAyne
DrawMap2
Stickaway
If count=0 Then
SDL_Text fo,100,200,"I found all sticks",SDL_RGB(255,255,255)
SDL_Text fo,100,240,"Let's go home",SDL_RGB(255,255,255)
If play=0 Then
PlayWav w1,0,1
play=1
EndIf
EndIf
SDL_Text fo,16,450,"STICKS " & count,SDL_RGB(255,255,255)
SDL_Sync
Wend
SDL_Quit