summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--GFX/PNG/BULLET.pngbin0 -> 224 bytes
-rw-r--r--GFX/PNG/MOUSE.pngbin0 -> 338 bytes
-rw-r--r--GFX/PNG/PLAYER.pngbin0 -> 343 bytes
-rw-r--r--GFX/PNG/PLAYERDEAD.pngbin0 -> 949 bytes
-rw-r--r--GFX/PNG/PLAYERHAPPY.pngbin0 -> 357 bytes
-rw-r--r--GFX/backdrop.bmpbin1440054 -> 0 bytes
-rw-r--r--GFX/button.pngbin0 -> 5483 bytes
-rw-r--r--GFX/earth.c4d (renamed from GFX/backdrop.c4d)bin106459 -> 106459 bytes
-rw-r--r--GFX/earth.pngbin0 -> 324058 bytes
-rw-r--r--GFX/font.bmfbin84480 -> 83712 bytes
-rw-r--r--GFX/font_shadow.bmfbin84480 -> 83712 bytes
-rw-r--r--GFX/layer1.pngbin0 -> 10110 bytes
-rw-r--r--GFX/layer2.pngbin0 -> 15450 bytes
-rw-r--r--GFX/sprites.bmsbin0 -> 15062 bytes
-rw-r--r--font_fade.bmx18
-rw-r--r--main.bmx340
-rw-r--r--menu.bmx76
-rw-r--r--players.bmx123
-rw-r--r--sprite.bmx94
19 files changed, 555 insertions, 96 deletions
diff --git a/GFX/PNG/BULLET.png b/GFX/PNG/BULLET.png
new file mode 100644
index 0000000..374e7ae
--- /dev/null
+++ b/GFX/PNG/BULLET.png
Binary files differ
diff --git a/GFX/PNG/MOUSE.png b/GFX/PNG/MOUSE.png
new file mode 100644
index 0000000..a860d90
--- /dev/null
+++ b/GFX/PNG/MOUSE.png
Binary files differ
diff --git a/GFX/PNG/PLAYER.png b/GFX/PNG/PLAYER.png
new file mode 100644
index 0000000..81c3a3e
--- /dev/null
+++ b/GFX/PNG/PLAYER.png
Binary files differ
diff --git a/GFX/PNG/PLAYERDEAD.png b/GFX/PNG/PLAYERDEAD.png
new file mode 100644
index 0000000..cea2717
--- /dev/null
+++ b/GFX/PNG/PLAYERDEAD.png
Binary files differ
diff --git a/GFX/PNG/PLAYERHAPPY.png b/GFX/PNG/PLAYERHAPPY.png
new file mode 100644
index 0000000..eb4218d
--- /dev/null
+++ b/GFX/PNG/PLAYERHAPPY.png
Binary files differ
diff --git a/GFX/backdrop.bmp b/GFX/backdrop.bmp
deleted file mode 100644
index 7e4a969..0000000
--- a/GFX/backdrop.bmp
+++ /dev/null
Binary files differ
diff --git a/GFX/button.png b/GFX/button.png
new file mode 100644
index 0000000..6e97350
--- /dev/null
+++ b/GFX/button.png
Binary files differ
diff --git a/GFX/backdrop.c4d b/GFX/earth.c4d
index 4183fe7..4183fe7 100644
--- a/GFX/backdrop.c4d
+++ b/GFX/earth.c4d
Binary files differ
diff --git a/GFX/earth.png b/GFX/earth.png
new file mode 100644
index 0000000..6abc6fe
--- /dev/null
+++ b/GFX/earth.png
Binary files differ
diff --git a/GFX/font.bmf b/GFX/font.bmf
index 373086f..897024b 100644
--- a/GFX/font.bmf
+++ b/GFX/font.bmf
Binary files differ
diff --git a/GFX/font_shadow.bmf b/GFX/font_shadow.bmf
index 1867516..97992e3 100644
--- a/GFX/font_shadow.bmf
+++ b/GFX/font_shadow.bmf
Binary files differ
diff --git a/GFX/layer1.png b/GFX/layer1.png
new file mode 100644
index 0000000..c0313da
--- /dev/null
+++ b/GFX/layer1.png
Binary files differ
diff --git a/GFX/layer2.png b/GFX/layer2.png
new file mode 100644
index 0000000..603017a
--- /dev/null
+++ b/GFX/layer2.png
Binary files differ
diff --git a/GFX/sprites.bms b/GFX/sprites.bms
new file mode 100644
index 0000000..8a10e53
--- /dev/null
+++ b/GFX/sprites.bms
Binary files differ
diff --git a/font_fade.bmx b/font_fade.bmx
index 62f5e82..0c9cd1b 100644
--- a/font_fade.bmx
+++ b/font_fade.bmx
@@ -3,12 +3,14 @@
'
' $Id$
'
-Type FontFade
+Import noddybox.bitmapfont
+
+Type TFontFade
Field list:TList
- Field font:BitmapFont
+ Field font:TBitmapFont
- Function Create:FontFade(f:BitmapFont)
- Local ff:FontFade=New FontFade
+ Function Create:TFontFade(f:TBitmapFont)
+ Local ff:TFontFade=New TFontFade
ff.list=New TList
ff.font=f
@@ -16,7 +18,7 @@ Type FontFade
Return ff
End Function
- Method Add(s:String, x:Float, y:Float, col:Int, a:Float, ai:Float, dx:Float, dy:Float)
+ Method Add(s:String, x:Float, y:Float, col:Int, a:Float=1.0, ai:Float=0.02, dx:Float=0.0, dy:Float=0.0)
Local f:FontFadeEnt=New FontFadeEnt
f.s=s
@@ -34,7 +36,7 @@ Type FontFade
list.AddLast(f)
End Method
- Method Centre(s:String, y:Float, col:Int, a:Float, ai:Float, dy:Float)
+ Method Centre(s:String, y:Float, col:Int, a:Float=1.0, ai:Float=0.02, dy:Float=0.0)
Local f:FontFadeEnt=New FontFadeEnt
f.s=s
@@ -74,9 +76,9 @@ Type FontFade
SetAlpha(f.a)
If f.centre
- font.CentreColoured(f.s,f.y,f.r,f.g,f.b)
+ font.Centre(f.s,f.y,f.r,f.g,f.b)
Else
- font.DrawColoured(f.s,f.x,f.y,f.r,f.g,f.b)
+ font.Draw(f.s,f.x,f.y,f.r,f.g,f.b)
EndIf
f.a:+f.ai
diff --git a/main.bmx b/main.bmx
index f360e90..4b91516 100644
--- a/main.bmx
+++ b/main.bmx
@@ -6,95 +6,240 @@
Strict
Import noddybox.bitmapfont
+Import noddybox.vector
' Includes
'
-Include "font_fade.bmx"
+Import "font_fade.bmx"
+Import "menu.bmx"
+Import "sprite.bmx"
+Import "players.bmx"
' Included binaries
'
Incbin "GFX/font.bmf"
Incbin "GFX/font_shadow.bmf"
-Incbin "GFX/backdrop.bmp"
+Incbin "GFX/earth.png"
+Incbin "GFX/layer1.png"
+Incbin "GFX/layer2.png"
+Incbin "GFX/button.png"
+Incbin "GFX/PNG/PLAYER.png"
+Incbin "GFX/PNG/PLAYERHAPPY.png"
+Incbin "GFX/PNG/PLAYERDEAD.png"
+Incbin "GFX/PNG/MOUSE.png"
+Incbin "GFX/PNG/BULLET.png"
+
+' Initialise graphics
+'
SetGraphicsDriver GLMax2DDriver()
Graphics 800,600,32,60
HideMouse
SetBlend(ALPHABLEND)
+' Consts
+'
+Const SPEED:Float=0.1
+Const MAX_SPEED:Float=2.0
+
' Globals
'
-Global font:BitmapFont=BitmapFont.Load("incbin::GFX/font.bmf",0)
-Global font_shadow:BitmapFont=BitmapFont.Load("incbin::GFX/font_shadow.bmf",0)
-Global quit:Int=True
-Global fade:FontFade=FontFade.Create(font)
-Global fade_shadow:FontFade=FontFade.Create(font_shadow)
-Global bdrop:TImage=LoadImage("incbin::GFX/backdrop.bmp",0)
+Global quit:Int=False
+Global music:Int=True
+Global sfx:Int=True
+
+' Global images
+'
+Global font:TBitmapFont=TBitmapFont.Load("incbin::GFX/font.bmf",0)
+Global font_shadow:TBitmapFont=TBitmapFont.Load("incbin::GFX/font_shadow.bmf",0)
+Global fade:TFontFade=TFontFade.Create(font)
+Global fade_shadow:TFontFade=TFontFade.Create(font_shadow)
+Global layer1:TImage=LoadImage("incbin::GFX/layer1.png",FILTEREDIMAGE)
+Global layer2:TImage=LoadImage("incbin::GFX/layer2.png",FILTEREDIMAGE)
+Global buttonimg:TImage=LoadImage("incbin::GFX/button.png",0)
+
+AutoMidHandle True
+Global earthimg:TImage=LoadImage("incbin::GFX/earth.png",0)
+AutoMidHandle False
-SetImageHandle(bdrop,400,300)
+' Load sprites
+'
+AutoMidHandle True
+Global mouse_cursor:TImage=LoadAnimImage("incbin::GFX/PNG/MOUSE.png",16,16,0,3,0)
+Global player_image:TImage=LoadAnimImage("incbin::GFX/PNG/PLAYER.png",16,16,0,2,0)
+Global bullet_image:TImage=LoadAnimImage("incbin::GFX/PNG/BULLET.png",8,8,0,2,0)
+AutoMidHandle False
-Intro()
+Global bdropx#=0
+Global bdropy#=0
+Global mouse:TSprite=TSprite.Create(mouse_cursor,5,True,False,0)
+Global actor:TPlayer=TPlayer.Create(player_image,bullet_image,3,False,True,1)
+
+' ----------------------------------------------
+' MAIN
+' ----------------------------------------------
+'
MainMenu()
While Not quit
MainMenu()
Wend
+EndGraphics
End
-Function StartPage(bground:Int=True,sx:Float=1,sy:Float=1)
+' ----------------------------------------------
+' UTILS
+' ----------------------------------------------
+'
+Function StartPage(bground:Int=False,dx:Float=0,dy:Float=0)
Cls
If bground
- Local x:Float,y:Float,r:Float,a:Float
- a=GetAlpha()
- r=GetRotation()
- GetScale(x,y)
-
- SetAlpha(2)
- SetTransform(0,sx,sy)
- DrawImage(bdrop,400,300)
- SetAlpha(a)
- SetTransform(r,x,y)
+ bdropx:+dx
+ bdropy:+dy
+ TileImage(layer2,bdropx/2,bdropy/2)
+ TileImage(layer1,bdropx,bdropy)
EndIf
End Function
Function EndPage(flush:Int=True)
- If flush Then FlushMem
+ SetTransform(0,1,1)
+ mouse.x=MouseX()
+ mouse.y=MouseY()
+ mouse.Update()
+ 'If flush Then FlushMem
Flip
End Function
-Function Intro()
- Local c=20
+' ----------------------------------------------
+' PLAYER CODE
+' ----------------------------------------------
+'
+Function InitPlayer()
+ actor.sprite.ChangeImage(player_image,1)
+ actor.NewGame()
+End Function
+
+
+Function MovePlayer()
+ If KeyDown(KEY_DOWN)
+ actor.sprite.v.y:+SPEED
+ ElseIf KeyDown(KEY_UP)
+ actor.sprite.v.y:-SPEED
+ ElseIf (actor.sprite.v.y<>0)
+ If (Abs(actor.sprite.v.y)>SPEED)
+ actor.sprite.v.y:-Sgn(actor.sprite.v.y)*SPEED
+ Else
+ actor.sprite.v.y=0
+ EndIf
+ EndIf
+
+ If KeyDown(KEY_RIGHT)
+ actor.sprite.v.x:+SPEED
+ ElseIf KeyDown(KEY_LEFT)
+ actor.sprite.v.x:-SPEED
+ ElseIf (actor.sprite.v.x<>0)
+ If (Abs(actor.sprite.v.x)>SPEED)
+ actor.sprite.v.x:-Sgn(actor.sprite.v.x)*SPEED
+ Else
+ actor.sprite.v.x=0
+ EndIf
+ EndIf
+
+ actor.sprite.v.y=Min(MAX_SPEED,Max(actor.sprite.v.y,-MAX_SPEED))
+ actor.sprite.v.x=Min(MAX_SPEED,Max(actor.sprite.v.x,-MAX_SPEED))
+
+ actor.AddBullet(MouseX(),MouseY())
+End Function
+
+
+
+' ----------------------------------------------
+' MENU
+' ----------------------------------------------
+'
+Function MainMenu()
Local a$
- Local f:FontFade=fade_shadow
+ Local txt$
+ Local f:TFontFade=fade_shadow
+ Local ang:Float=0
+ Local tx:Int=0
+ Local done:Int=False
+
+ Local menu:TMenu=TMenu.Create(font,buttonimg,100)
- SetTransform(0,2,2)
+ menu.Add("PLAY!")
+ menu.Add("HOW TO PLAY")
+ menu.Add("EFFECTS ON/OFF")
+ menu.Add("MUSIC ON/OFF")
+ menu.Add("QUIT")
RestoreData intro_data
- While Not KeyHit(KEY_SPACE)
- StartPage()
+ ReadData a$
+
+ While a$<>"XXX"
+ txt:+a$
+ ReadData a$
+ Wend
+
+ While Not done
+ StartPage(True,0.2,0.5)'Sin(ang),Cos(ang*2))
- c:-1
+ SetTransform(0,1,1)
- If c=0
- c=20
-
- ReadData a$
-
- If a$="XXX"
- RestoreData intro_data
- c=200
- Else
- f.Centre(a$,500,$ffff80,0,0.008,-2)
- EndIf
+ font_shadow.Centre("NUTTER SHOOT",0)
+ font_shadow.Centre("(C) IAN C 2005",30)
+
+ Select menu.Render()
+ Case "PLAY!"
+ done=True
+ Case "HOW TO PLAY"
+ HowToPlay()
+ Case "MUSIC ON/OFF"
+ music=Not music
+ Case "EFFECTS ON/OFF"
+ sfx=Not sfx
+ Case "QUIT"
+ done=True
+ quit=True
+ EndSelect
+
+ If KeyDown(KEY_ESCAPE)
+ done=True
+ quit=True
EndIf
- f.Process()
+ ang:+0.5
+
+ SetTransform(0,2,2)
+
+ If music
+ font.Draw("a",0,0)
+ Else
+ font.Draw("b",0,0)
+ EndIf
+
+ If sfx
+ font.Draw("c",40,0)
+ Else
+ font.Draw("d",40,0)
+ EndIf
+
+ SetTransform(0,2,2)
+
+ font_shadow.Draw(txt$,tx,550,255,255,100)
+
+ tx:-3
+
+ If tx<-font.TextWidth(txt[0..1])
+ tx:+font.TextWidth(txt[0..1])
+ txt=txt[1..]+txt[0..1]
+ EndIf
EndPage()
Wend
@@ -102,66 +247,85 @@ Function Intro()
End Function
-Function MainMenu()
-End Function
-
-
-Rem
-sc=10
-t$="THIS IS SOME VERY, VERY, *VERY* ~~LARGE SCROLLING TEXT....."
-x#=0
-ang#=0
-angi#=0.2
-
-While Not KeyHit(KEY_ESCAPE)
- Cls
-
- For f=0 Until NO
- st[f].Update()
- Next
+Function HowToPlay()
+ Local txt$
+ Local col:Int
+ Local f:TFontFade=fade_shadow
+ Local done:Int=False
+ Local y:Int
+ Local menu:TMenu=TMenu.Create(font,buttonimg,530)
- SetTransform(ang,sc,sc)
+ SetTransform(0,1,1)
+ InitPlayer()
- ang:+angi
+ actor.sprite.y=80
+
+ f.Clear()
- If ang<=-10 Or ang>=10 Then angi=-angi
-
- fnt.DrawColoured(t$,x,0,255,255,255)'128,128)
+ menu.Add("BACK")
- If Not KeyDown(KEY_P)
- x:-5
+ While Not done
+ StartPage()
+
+ MovePlayer()
- If x<-fnt.TextWidth(t[0..1])
- x:+fnt.TextWidth(t[0..1])
- t=t[1..]+t[0..1]
+ actor.Update()
+
+ If f.IsEmpty()
+ RestoreData tutor_data
+ ReadData txt$
+ y=100
+
+ While txt$<>"XXX"
+ ReadData col
+ f.Centre(txt$,y,col,0.02,0.02)
+ ReadData txt$
+ y:+20
+ Wend
EndIf
- EndIf
- FlushMem
-
- Flip
+ f.Process()
+
+ Select menu.Render()
+ Case "BACK"
+ done=True
+ EndSelect
+
+ If KeyDown(KEY_ESCAPE)
+ done=True
+ quit=True
+ EndIf
+
+ EndPage()
+ Wend
-Wend
+ f.Clear()
+End Function
-End Rem
' PROGRAM DATA
'
#intro_data
- DefData "NUTTER SHOOT"
- DefData " "
- DefData "(C) IAN C 2005"
- DefData " "
- DefData "THIS IS FREE SOFTWARE."
- DefData "SEE THE GNU GENERAL"
- DefData "PUBLIC LICENSE FOR"
- DefData "DETAILS."
- DefData " "
- DefData " "
- DefData "PRESS SPACE TO PLAY"
- DefData " "
- DefData " "
+ DefData " "
+ DefData " "
+ DefData "SAVE THE EARTH FROM "
+ DefData "THE PERIL OF BADLY DRAWN SPRITES "
+ DefData "AFTER THE BLOOD OF THEIR FORMER MASTERS..."
+ DefData " "
DefData "DEVELOPED WITH BLITZMAX"
- DefData "HTTP://WWW.BLITZBASIC.COM"
+ DefData " "
+ DefData "XXX"
+
+#tutor_data
+ DefData "THIS LITTLE SPRITE IS YOU...",$ff0000
+ DefData "IT RUNS AROUND WHEN YOU PRESS THE CURSOR KEYS",$ff0000
+ DefData "AIM WITH THE MOUSE",$ff0000
+ DefData " ",$ff0000
+ DefData "TRY IT NOW!",$ffff00
+ DefData " ",$ff0000
+ DefData "SHOOT THINGS. DON'T RUN INTO THINGS.",$ff0000
+ DefData "DON'T GET SHOT. DON'T FORGET TO FLOSS.",$ff0000
+ DefData "THESE ARE THE RULES!",$ffff00
+ DefData " ",$ff0000
DefData "XXX"
diff --git a/menu.bmx b/menu.bmx
new file mode 100644
index 0000000..b441a0f
--- /dev/null
+++ b/menu.bmx
@@ -0,0 +1,76 @@
+'
+' Provides simple menus
+'
+' $Id$
+'
+Import noddybox.bitmapfont
+
+Type TMenu
+ Field list:TList
+ Field img:TImage
+ Field font:TBitmapFont
+ Field ypos:Int
+ Field xpos:Int
+ Field yoff:Int
+ Field w:Int
+ Field h:Int
+ Field count:Int
+ Field mbdown:Int
+
+ Function Create:TMenu(f:TBitmapFont, img:TImage, y:Int)
+ Local menu:TMenu=New TMenu
+
+ menu.list=New TList
+ menu.img=img
+ menu.font=f
+ menu.ypos=y
+ menu.w=ImageWidth(img)
+ menu.h=ImageHeight(img)
+ menu.xpos=GraphicsWidth()/2-menu.w/2
+ menu.yoff=menu.h/2-f.TextHeight("X")/2
+ menu.mbdown=False
+ Return menu
+ End Function
+
+ Method Add(s:String)
+ list.AddLast(s)
+ End Method
+
+ ' Returns the selected item, or "" for none
+ '
+ Method Render:String()
+ Local y:Int=ypos
+ Local in:String=""
+ Local mx:Int=MouseX()
+ Local my:Int=MouseY()
+ Local any:Int=False
+
+ For Local s:String=EachIn list
+ If (mx>xpos And mx<xpos+w And my>y And my<y+h)
+ If KeyDown(KEY_MOUSELEFT)
+ mbdown=True
+ DrawImage(img,xpos,y+2)
+ font.Centre(s,y+yoff+2,255,255,0)
+ any=True
+ Else
+ DrawImage(img,xpos,y)
+ font.Centre(s,y+yoff,255,255,0)
+ If mbdown
+ in=s
+ EndIf
+ mbdown=False
+ EndIf
+ Else
+ DrawImage(img,xpos,y)
+ font.Centre(s,y+yoff,128,128,0)
+ EndIf
+ y:+h+20
+ Next
+
+ If Not any
+ mbdown=False
+ EndIf
+
+ Return in
+ End Method
+End Type \ No newline at end of file
diff --git a/players.bmx b/players.bmx
new file mode 100644
index 0000000..cda263a
--- /dev/null
+++ b/players.bmx
@@ -0,0 +1,123 @@
+'
+' Actor objects
+'
+' $Id$
+'
+Import "sprite.bmx"
+
+Type TActor Abstract
+ ' These fields are public
+ '
+ Field sprite:TSprite
+
+ ' These fields are private
+ '
+ Field m_bullets:TList
+ Field m_bullet:TImage
+ Field m_bullet_del:Int
+ Field m_init_del:Int
+ Field m_bullet_speed:Float
+
+ Method InitActor(img:TImage,bullet:TImage,bullet_del:Int,bullet_speed:Float,anim_speed:Int,ping_pong:Int,anim_with_delta:Int,col_mask:Int)
+ sprite=TSprite.Create(img,anim_speed,ping_pong,anim_with_delta,col_mask)
+
+ m_bullet=bullet
+ m_bullets=CreateList()
+ m_bullet_del=bullet_del
+ m_init_del=bullet_del
+ m_bullet_speed=bullet_speed
+
+ sprite.x=0
+ sprite.y=0
+ sprite.v.x=0
+ sprite.v.y=0
+ End Method
+
+ Method Centre()
+ sprite.x=GraphicsWidth()/2
+ sprite.y=GraphicsHeight()/2
+ sprite.v.x=0
+ sprite.v.y=0
+ End Method
+
+ Method Update()
+ sprite.Update()
+
+ For Local s:TSprite=EachIn m_bullets
+ s.Update()
+ Next
+ End Method
+
+ Method AddBullet(x:Int,y:Int)
+ Local dx:Int=x-sprite.x
+ Local dy:Int=y-sprite.y
+
+ If (dx=0 And dy=0)
+ Return
+ EndIf
+
+ If m_bullet_del=0
+ m_bullet_del=m_init_del
+
+ If (m_bullets.Count()>50)
+ m_bullets.RemoveFirst()
+ EndIf
+
+ Local s:TSprite=TSprite.Create(m_bullet,2,False,False,0)
+
+ s.x=sprite.x
+ s.y=sprite.y
+
+ s.v.x=dx
+ s.v.y=dy
+
+ s.v.Normalise()
+ s.v.Scale(m_bullet_speed)
+
+ m_bullets.AddLast(s)
+ Else
+ m_bullet_del:-1
+ EndIf
+ End Method
+End Type
+
+
+Type TPlayer Extends TActor
+ ' These fields are public
+ '
+ Field lives:Int
+
+ Function Create:TPlayer(img:TImage,bullet:TImage,anim_speed:Int,ping_pong:Int,anim_with_delta:Int,col_mask:Int)
+ Local p:TPlayer=New TPlayer
+
+ p.InitActor(img,bullet,10,4,anim_speed,ping_pong,anim_with_delta,col_mask)
+ p.lives=3
+
+ Return p
+ End Function
+
+ Method NewGame()
+ Centre()
+ lives=3
+ m_bullets.Clear()
+ m_bullet_del=m_init_del
+ End Method
+
+ Method ResetPosition()
+ sprite.x=GraphicsWidth()/2
+ sprite.y=GraphicsHeight()/2
+ sprite.v.x=0
+ sprite.v.y=0
+ End Method
+End Type
+
+Type TEnemy Extends TActor
+ Function Create:TEnemy(img:TImage,bullet:TImage,bullet_del:Int,bullet_speed:Float,anim_speed:Int,ping_pong:Int,anim_with_delta:Int,col_mask:Int)
+ Local p:TEnemy=New TEnemy
+
+ p.InitActor(img,bullet,bullet_del,bullet_speed,anim_speed,ping_pong,anim_with_delta,col_mask)
+
+ Return p
+ End Function
+End Type
+
diff --git a/sprite.bmx b/sprite.bmx
new file mode 100644
index 0000000..94ab084
--- /dev/null
+++ b/sprite.bmx
@@ -0,0 +1,94 @@
+'
+' Provides sprite wrappers routines
+'
+' $Id$
+'
+Import noddybox.vector
+
+Type TSprite
+ Field x:Float
+ Field y:Float
+ Field v:TVector
+
+ ' These fields are private
+ '
+ Field img:TImage
+ Field frames:Int
+ Field pong:Int
+ Field fr:Int
+ Field colmask:Int
+ Field aninmove:Int
+ Field animspeed:Int
+ Field animframe:Int
+ Field animframeinc:Int
+
+ Function Create:TSprite(i:TImage,anim_speed:Int,ping_pong:Int,anim_with_delta:Int,col_mask:Int)
+ Local s:TSprite=New TSprite
+
+ s.img=i
+ s.frames=i.frames.length-1
+ s.fr=0
+ s.colmask=col_mask
+ s.animframe=0
+ s.animframeinc=1
+ s.pong=ping_pong
+ s.aninmove=anim_with_delta
+ s.animspeed=anim_speed
+
+ s.v=TVector.Create(0,0,0)
+
+ s.x=0
+ s.y=0
+ s.v.x=0
+ s.v.y=0
+
+ Return s
+ End Function
+
+ Method ChangeAnim(anim_speed:Int,ping_pong:Int,anim_with_delta:Int)
+ pong=ping_pong
+ aninmove=anim_with_delta
+ animspeed=anim_speed
+ End Method
+
+ Method ChangeImage(i:TImage,col_mask)
+ img=i
+ frames=i.frames.length-1
+ colmask=col_mask
+ animframe=0
+ animframeinc=1
+ End Method
+
+ Method Update()
+ x:+v.x
+ y:+v.y
+
+ DrawImage(img,x,y,animframe)
+
+ If (colmask<>0)
+ CollideImage(img,x,y,animframe,0,colmask,Self)
+ EndIf
+
+ fr:+1
+
+ If (frames>0 And ((Not aninmove) Or v.x<>0 Or v.y<>0))
+
+ If (fr>animspeed)
+ fr=0
+
+ animframe:+animframeinc
+
+ If (pong)
+ If (animframe=0 Or animframe=frames)
+ animframeinc=-animframeinc
+ EndIf
+ Else
+ If (animframe>frames)
+ animframe=0
+ EndIf
+ EndIf
+ EndIf
+ EndIf
+ End Method
+
+End Type \ No newline at end of file