|
Nah; I'm not gunna prevent activity just to perpetuate something I don't necessarily support I'd rather work on what we have here, since no matter what happens, we always have this as a fallback ;p Anyway-------------------> lol I'm making a quick frogger game to familiarize myself with Blitz a bit more. Most people do Hello World apps, but I do frogger Source has been updated considerably- 'Main Blitz Frogger ' 'Handles main loop. ' '2009 Mamoruanime '
'Pre-loop setup----------- Strict HideMouse Graphics 224,256,0 SetViewport(0,0,224,256) AppTitle = "Blitz Frogger" '-------------------------
'Includes----------------- Include "tIntro.bmx" 'Intro Routines Include "tMap.bmx" 'Map Drawing Routines Include "tText.bmx" 'Font stuff Include "tMisc.bmx" 'Misc functions '-------------------------
'Intro Loop--------------- While Not KeyDown(KEY_ENTER) While CountList(introfroglist) < 7 CreateIntroFrog((CountList(introfroglist) + 1)) DebugLog String(CountList(introfroglist)) Wend DrawBackColors() UpdateIntroFrogs() DrawSpriteText("1-Up",32,0,255,255,255) DrawSpriteText("HI-SCORE",80,0,255,255,255) GetFPS() Flip;Cls Wend '-------------------------
'Main Loop---------------- While Not KeyDown(KEY_ESCAPE) RenderMap(-1) GetFPS() Flip;Cls Wend '------------------------- 'tMap Blitz Frogger ' 'Handles map rendering. ' '2009 Mamoruanime '
Incbin "tiles.png"
Function DrawBackColors() SetColor(0,0,71) 'Blue water top DrawRect(0,0,224,128) SetColor(0,0,0) 'Black Pavement DrawRect(0,128,224,128) EndFunction
Function RenderMap(tileflags:Int) 'Local Variables. Local imgTiles:timage = LoadAnimImage("tiles.png",16,16,0,16,tileflags) Local tilemap:String = "000000000000001271271271271256856856856856000000000000000000000000000000000000000000000000000000000000000000000033333333333333000000000000000000000000000000000000000000000000000000000000000000000033333333333333" Local tilepos:Int = 1 'Position on tilemap var. Indicates which tile to place. Local tileatpos:Int = 0 'Current integer on the tilemap. Local xpos:Int = 0 'X Position that resets every 14 tile placements. Local ypos:Int = 0 'Y Position of our placement.
'Begin by drawing the two main backdrop colors (blue water, black pavement). DrawBackColors() SetColor(255,255,255) 'Default Color SetMaskColor(255,0,255) 'Mask Color 'Start rendering the tilestream on top of the color rectangles. While tilepos <> (Len(tilemap)+1) tileatpos = Int(Mid(tilemap,tilepos,1)) If tileatpos <> 0 DrawImage(imgTiles,(xpos*16),(ypos*16), (tileatpos - 1)) EndIf If xpos < 13 'Keep adding to your X position, then place the tile. xpos:+ 1 Else 'Once you reach your final X position, go down 1 Y position, then back to 0 X. xpos = 0 ypos:+ 1 EndIf tilepos:+ 1 'Move forward on your tilemap string. Wend
EndFunction
Function Mode7Emulation() 'todo: Use GrabImage() to make an image out of the drawn background, and then 'transform it further using other functions to give a sense of depth. EndFunction 'tIntro Blitz Frogger ' 'Houses intro routines ' '2009 Mamoruanime ' Global introfroglist:TList = CreateList() Incbin "introtiles.png"
'Function to create your intro frogs.
Function CreateIntroFrog(index:Int) Local frog:tIntroFrog frog = New tIntroFrog frog.index = index frog.count = (index * frog.duration) Select index Case 1 frog.titleletter = 0 Case 2 frog.titleletter = 1 Case 3 frog.titleletter = 2 Case 4 frog.titleletter = 3 Case 5 frog.titleletter = 3 Case 6 frog.titleletter = 4 Case 7 frog.titleletter = 1 EndSelect ListAddLast(introfroglist,frog) EndFunction
Function UpdateIntroFrogs()
For Local frog:tIntroFrog = EachIn introfroglist frog.Update() Next
EndFunction
'Intro frog object.
Type tIntroFrog Field duration:Int = 32 'Milliseconds until change. Field count:Int 'Count until change. Field index:Int 'What order was this created? Field titleletter:Int 'Letter this turns into. Field titlesprite:timage = LoadAnimImage("introtiles.png",16,16,0,16,-1) Method Update() If count > 0 count:- 1 EndIf Draw() EndMethod
Method Draw() 'Draw the logo If count > 0 SetColor(255,255,255) DrawImage(titlesprite,(8 + (index * 24)),52,5) 'Draw the default frog image. Else SetColor(255,255,255) DrawImage(titlesprite,(8 + (index * 24)),52,titleletter) 'Now draw the letter. EndIf EndMethod
EndType
'tText Blitz Frogger ' 'Routines for the font ' '2009 Mamoruanime '
Incbin "font.png"
Function DrawSpriteText(Str:String,x:Int,y:Int, colorr:Int, colorg:Int, colorb:Int) 'This is simply a replacement for the DrawText function. Local strpos:Int = 0 Local stratpos:String Local spacingx:Int = 8 Local realstr:String = Upper(Str) Local fontspr:timage = LoadAnimImage("font.png",8,8,0,37,-1) While strpos <= Len(Str) stratpos = Upper(Mid(str,strpos,1)) SetColor(255,255,255) If stratpos <> " " And stratpos <> "" And stratpos <> "-" If stratpos <> "0" And stratpos <> "1" And stratpos <> "2" And stratpos <> "3" And stratpos <> "4" And stratpos <> "5" And stratpos <> "6" And stratpos <> "7" And stratpos <> "8" And stratpos <> "9" DrawImage(fontspr,(x+(8*strpos)) - 8,y,(Asc(stratpos)-55)) Else DrawImage(fontspr,(x+(8*strpos)) - 8,y,(Asc(stratpos)-48)) EndIf Else If stratpos = "-" DrawImage(fontspr,(x+(8*strpos)) - 8,y,36) EndIf strpos:+ 1 Wend EndFunction 'tMisc Blitz Frogger ' 'Misc functions. ' '2009 Mamoruanime '
Global ticks:Int Global ticksbeforeswitch:Int Global endtime:Int
Function GetFPS() If MilliSecs() < endtime ticks:+1 Else ticksbeforeswitch = ticks endtime = MilliSecs() + 1000 ticks = 0 EndIf DrawSpriteText("FPS "+String(ticksbeforeswitch) ,0,248,255,255,255)
EndFunction And the result is this:
Logged
|