Oxygen Basic
Programming => Example Code => Topic started by: Peter on January 20, 2011, 06:18:48 AM
-
Deleted
[attachment deleted by admin]
-
Thanks Peter. You are building up a substantial collection of demos. Some of your earlier pieces became incompatible with the newer lib_G. Should we fix them so they all run with the same win_G etc or keep them separate?
Charles
-
Hi, nice job.
[Offtopic]
The only thing that is weird to me is that there is no indentation in the code :o
How do people manage to not get lost in the code without some sort of indentation?
Maybe it's just me: an old man with failing sight, brain, etc. ;D
I need proper rules man; otherwise I'm lost ;)
[/Offtopic]
-
There is an indenting utility in tools\
It reads code from file t.txt and produces indented code in t.o2bas
Developed especially for Peter :)
Charles
IndexBase 0
Include Once "Win_G.inc"
Declare Function LoadBitmap Lib "A.Dll" (byval hdc as long, byval sFile As String, byval x as long, byval y As Long) as long
Declare Function DrawBitmap Lib "A.Dll" (byval hdc as long, byval sHdc As Long, byval x1 As Long, byval y1 As Long)
Declare Function FreeBitmap Lib "A.Dll" (byval bHnd as long)
Declare Function SetFont Lib "A.Dll" (byval hdc As Long, byval width As Long, byval height As long, byval flags As Long,byval font As string) As Long
Declare Function DrawText Lib "A.Dll" (byval hdc as long, byval text as string, byval x3 as long, byval y3 as long, byval color as long)
Declare Function FreeFont Lib "A.Dll" (byval font as long)
Declare Function LoadSprite Lib "A.Dll" (byval hdc as long,byval sFile As String, byval sWidth As Long, byval sHeight As Long) As Long
Declare Function DrawSprite Lib "A.Dll" (byval hdc as long, byval Num As Long, byval x1 As Long, byval y1 As Long, byval zx As Long, byval zy As Long, byval Frame As Long)
Declare Function FreeSprite Lib "A.Dll" (byval sHnd As Long)
Declare Function SetFps Lib "A.Dll" (byval Frame as long)
Declare Function WaitFps Lib "A.Dll" ()
/* OWN DECLARES */
Declare Function You()
Declare Function Move()
Dim youR,youL,youU,youD,CirU,CirD,Fire,p1,p1,p3,p4,sx,sy,sr,sz,sf,xsr,ysr as long
Dim aFont,bHdc as long
SetWindow "OxygenBasic o26", 800, 600, ws_overlapped
bHdc = SetImage 1600,1200
aFont = SetFont bHdc,16,24,FW_BOLD,"times" '-> times/courier/symbol/""
SetFps 120
youR = LoadSprite bHdc,"media/youR.bmp",32,32
youL = LoadSprite bHdc,"media/youL.bmp",32,32
youU = LoadSprite bHdc,"media/youU.bmp",32,32
youD = LoadSprite bHdc,"media/youD.bmp",32,32
cirD = LoadSprite bHdc,"media/cirD.bmp",32,32
cirU = LoadSprite bHdc,"media/cirU.bmp",32,32
p1 = LoadBitmap bHdc,"media/G1.bmp",800,600
p2 = LoadBitmap bHdc,"media/G2.bmp",800,600
p3 = LoadBitmap bhdc,"media/G3.bmp",800,600
p4 = LoadBitmap bhdc,"media/G4.bmp",880,600
sy =100: sr =1: sf =0
While WinExit =0
DrawBitmap bHdc,p1, 0, 0
DrawBitmap bHdc,p2,800,0
DrawBitmap bHdc,p3,0,600
DrawBitmap bHdc,p4,800,600
Move
You
DrawText bHdc, "THIS IS MY MEADOW.",220,118, RGB(170,250,155)
DoEvents
FlipImageRect 0,0,800,600,xsr,ysr '-> FlipBuffer is not necessary!
WaitFps
Wend
FreeSprite youL: FreeSprite youU '-> next, we will get FREEIMAGES for all the Graphics!
FreeSprite youR: FreeSprite youD
FreeSprite cirU: FreeSprite cirD
FreeBitmap p1 : FreeBitmap p2
FreeBitmap p3 : FreeBitmap p4
FreeFont aFont
WinEnd
Function Move()
iF Key(vk_up) and sr =1 and sf =0
sf = -1
ElseiF Key(vk_down) and sr =1 and sf =0
sf = -2
ElseiF Key(vk_up) and sr =2 and sf =0
sf = -3
ElseiF Key(vk_down) and sr =2 and sf =0
sf = -4
ElseiF Key(vk_right) and sr =3 and sf =0
sf = -5
ElseiF Key(vk_left) and sr =3 and sf =0
sf = -6
ElseiF Key(vk_right) and sr =4 and sf =0
sf = -7
ElseiF Key(vk_left) and sr =4 and sf =0
sf = -8
ElseiF Key(vk_left) and sr =1 and sf =0
sf = -9
ElseiF Key(vk_right) and sr =2 and sf =0
sf = -10
ElseiF Key(vk_up) and sr =4 and sf =0
sf = -11
ElseiF Key(vk_down) and sr =3 and sf =0
sf = -12
ElseiF Key(vk_right) and sx <1600-40 and sf =0
sx +=1: sr =1
iF sx >320 and sx <1120 Then xsr +=1
ElseiF Key(vk_left) and sx >0 and sf =0
sx -=1: sr =2
iF sx >=320 and sx <1120 Then xsr -=1
ElseiF Key(vk_up) and sy >0 and sf =0
sy -=1: sr =3
iF sy <=900 and sy >280 Then ysr -=1
ElseiF Key(vk_down) and sy <1200 -40 and sf =0
sy +=1: sr =4
iF sy >280 and sy <=900 Then ysr +=1
End iF
End Function
Function You()
iF sf = -1
DrawSprite bHdc,cirU,sx,sy,40,40,sz
sz +=1
iF sz =8
sz =0: sf =0: sr =3
End iF
ElseiF sf = -2
DrawSprite bHdc,cirD,sx,sy,40,40,sz
sz +=1
iF sz =8
sz =0: sf =0: sr =4
End iF
ElseiF sf = -3
DrawSprite bHdc,cirD,sx,sy,40,40,sz+16
sz +=1
iF sz =8
sz =0: sf =0: sr =3
End iF
ElseiF sf = -4
DrawSprite bHdc,cirU,sx,sy,40,40,sz+16
sz +=1
iF sz =8
sz =0: sf =0: sr =4
End iF
ElseiF sf = -5
DrawSprite bHdc,cirD,sx,sy,40,40,sz+24
sz +=1
iF sz =8
sz =0: sf =0: sr =1
End iF
ElseiF sf = -6
DrawSprite bHdc,cirU,sx,sy,40,40,sz+8
sz +=1
iF sz =8
sz =0: sf =0: sr =2
End iF
ElseiF sf = -7
DrawSprite bHdc,cirU,sx,sy,40,40,sz+24
sz +=1
iF sz =8
sz =0: sf =0: sr =1
End iF
ElseiF sf = -8
DrawSprite bHdc,cirD,sx,sy,40,40,sz+8
sz +=1
iF sz =8
sz =0: sf =0: sr =2
End iF
ElseiF sf = -9
DrawSprite bHdc,cirU,sx,sy,40,40,sz
sz +=1
iF sz =16
sz =0: sf =0: sr =2
End iF
ElseiF sf = -10
DrawSprite bHdc,cirD,sx,sy,40,40,sz+16
sz +=1
iF sz =16
sz =0: sf =0: sr =1
End iF
ElseiF sf = -11
DrawSprite bHdc,cirD,sx,sy,40,40,sz+8
sz +=1
iF sz =16
sz =0: sf =0: sr =3
End iF
ElseiF sf = -12
DrawSprite bHdc,cirU,sx,sy,40,40,sz+8
sz +=1
iF sz =16
sz =0: sf =0: sr =4
End iF
ElseiF sr =1
DrawSprite bHdc,youR,sx,sy,40,40,0
ElseiF sr =2
DrawSprite bHdc,youL,sx,sy,40,40,0
ElseiF sr =3
DrawSprite bHdc,youU,sx,sy,40,40,0
ElseiF sr =4
DrawSprite bHdc,youD,sx,sy,40,40,0
End iF
End Function