2
0
Эх сурвалжийг харах

Merge pull request #181 from GWRon/misc_sdlrendermax_samples

[Misc] Samples use SDLRenderMax2d now (if feasible)
Brucey 1 жил өмнө
parent
commit
333d045843

+ 35 - 35
samples/aaronkoolen/AStar/astar_demo.bmx

@@ -1,4 +1,4 @@
-Strict
+SuperStrict
 '
 ' Simple demo program of an astar path finding algorithm
 ' The GUI is pretty crappy
@@ -21,10 +21,10 @@ End
 Private
 ' Small class that encapsulates a position on the map
 Type MapPos
-	Method isAtPos(otherX, otherY)
+	Method isAtPos:Int(otherX:Int, otherY:Int)
 		Return otherX = x And otherY = y
 	End Method
-	Field x,y
+	Field x:Int,y:Int
 End Type
 
 
@@ -34,7 +34,7 @@ Type Terrain
 		_weight = weight
 		_image = LoadImage(filename)
 	End Method
-	Field _colour_r,_color_g,_color_b
+	Field _colour_r:Int,_color_g:Int,_color_b:Int
 	Field _weight:Int
 	Field _image:TImage
 End Type
@@ -56,10 +56,10 @@ Type AStarDemo
 	Field nodeMap:AStarNode[mapWidth, mapHeight]
 	Field startPos:MapPos
 	Field endPos:MapPos
-	Field currentMap = 0
+	Field currentMap:Int = 0
 
 ' Terrain information
-	Const numTerrainTypes = 4
+	Const numTerrainTypes:Int= 4
 	Field terrainFilenames:String[] = [ "road.png", "mountain.png", "water.png", "tree.png" ]
 	Field terrainWeights:Int[] = [ 1, -1, 4, 2 ]
 	Field terrains:Terrain[numTerrainTypes]
@@ -69,14 +69,14 @@ Type AStarDemo
 
 ' Path finding stuff
 ' Distance
-	Const numDistanceFunctions = 4	
+	Const numDistanceFunctions:Int = 4	
 ' Is there a DATA like statement in Blitz?
 	Field distanceNames:String[] = [ 	"(D) Euclidean Sqr(dx*dx+dy*dy)", ..
 									 	"(D) Pseudo Euclidean dx*dx+dy*dy", ..
 										"(D) Manhatten dx+dy", ..
 										"(D) Diagonal Shortcut dx>dy ? 1.4*dy + (dx-dy) : 1.4*dx + (dy-dx)" ]
 
-	Field distanceFunction = AStarGraphWalker.distanceEuclidean	
+	Field distanceFunction:Int = AStarGraphWalker.distanceEuclidean	
 
 ' Whether we're allowed to chage the costs with the "Q" and "W" keys
 	Field costChangeAllowed:Int 	= 0
@@ -156,8 +156,8 @@ Type AStarDemo
 
 			Local m:Int = MouseDown(1)
 
-			Local blockX = MouseX() / blockWidth
-			Local blockY = MouseY() / blockHeight
+			Local blockX:Int = MouseX() / blockWidth
+			Local blockY:Int = MouseY() / blockHeight
 
 			If m
 				handleMouseDown(blockX, blockY)
@@ -189,7 +189,7 @@ Type AStarDemo
 
 	Method processIncreaseTerrainCost()
 		If KeyHit(KEY_W)
-			Local t
+			Local t:Int
 			For t = 0 To numTerrainTypes - 1
 				terrains[t]._weight = terrains[t]._weight * 5
 			Next
@@ -200,7 +200,7 @@ Type AStarDemo
 
 	Method processDecreaseTerrainCost()
 		If KeyHit(KEY_Q) And costChangeAllowed > 0
-			Local t
+			Local t:Int
 			For t = 0 To numTerrainTypes - 1
 				terrains[t]._weight = terrains[t]._weight / 5
 			Next
@@ -280,7 +280,7 @@ Type AStarDemo
 	End Method
 
 ' Use this to change a map block while editing, so that redraws are sped up
-	Method setMapBlock(blockX, blockY, block)
+	Method setMapBlock(blockX:Int, blockY:Int, block:Int)
 		map[blockX, blockY] = block
 	End Method
 
@@ -302,7 +302,7 @@ Type AStarDemo
 		If stream = Null
 			Return "Error saving map"
 		EndIf
-		Local x,y;
+		Local x:Int,y:Int;
 		For y = 0 To mapHeight - 1
 			For x = 0 To mapWidth - 1
 				WriteInt(stream,map[x,y])
@@ -321,7 +321,7 @@ Type AStarDemo
 		If stream = Null
 			Return
 		EndIf
-		Local x,y;
+		Local x:Int,y:Int;
 		For y = 0 To mapHeight - 1
 			For x = 0 To mapWidth - 1
 				map[x,y] = ReadInt(stream)
@@ -407,7 +407,7 @@ Type AStarDemo
 	End Method
 
 ' Are the block coordinates with in the map area?
-	Method blockInMapArea(blockX:Int, blockY:Int)
+	Method blockInMapArea:Int(blockX:Int, blockY:Int)
 		Return blockX >= 0 And blockY >= 0 And blockX < mapWidth And blockY < mapHeight 
 	End Method
 
@@ -426,7 +426,7 @@ Type AStarDemo
 ' Draw the information text in the editor
 	Method drawInfo()
 ' Clear 
-		Local y = mapButtonBlockY * blockHeight + blockHeight
+		Local y:Int = mapButtonBlockY * blockHeight + blockHeight
 		SetColor 0,0,0
 		DrawRect 0, y, blockAreaWidth, blockHeight*5
 
@@ -471,10 +471,10 @@ Type AStarDemo
 	End Method
 
 	Method drawMapButtons()
-		Local y = mapButtonBlockY * blockHeight
-		Local x = mapButtonBlockX * blockWidth
-		Local startX = x
-		Local t
+		Local y:Int = mapButtonBlockY * blockHeight
+		Local x:Int = mapButtonBlockX * blockWidth
+		Local startX:Int = x
+		Local t:Int
 		Local output:String
 		For t = 0 To 9
 			If t < 8 
@@ -503,11 +503,11 @@ Type AStarDemo
 	End Method
 
 	Method drawTerrains()
-		Local t
+		Local t:Int
 		For t = 0 To numTerrainTypes - 1
 			Local terrain:Terrain = terrains[t]
-			Local x = terrainLegendBlockX * blockWidth
-			Local y = (terrainLegendBlockY + t)* blockHeight
+			Local x:Int = terrainLegendBlockX * blockWidth
+			Local y:Int = (terrainLegendBlockY + t)* blockHeight
 
 			SetColor 0,0,0
 			DrawRect x, y, blockWidth * 5, blockHeight
@@ -527,7 +527,7 @@ Type AStarDemo
 	Method drawMap()
 		SetColor 0,0,0
 		DrawRect 0, 0, blockAreaWidth, blockAreaHeight
-		Local x,y;
+		Local x:Int,y:Int;
 		For y = 0 To mapHeight - 1
 			For x = 0 To mapWidth - 1
 				drawMapBlock(x,y)
@@ -549,7 +549,7 @@ Type AStarDemo
 		SetScale 1,1
 	End Method
 
-	Method drawOnMap(x:Int, y:Int, r,g,b, margin:Int)
+	Method drawOnMap(x:Int, y:Int, r:Int,g:Int,b:Int, margin:Int)
 		SetColor r,g,b
 		DrawRect x * blockWidth + margin, y * blockHeight + margin, blockWidth - margin * 2, blockHeight - margin * 2
 	End Method
@@ -567,7 +567,7 @@ Type AStarDemo
 		SetColor 255,255,255
 		SetMaskColor 255,0,255
 		SetScale 1,1
-		Local t
+		Local t:Int
 		For t = 0 To Len(s) - 1
 			DrawImage nums, x, y, Byte(s[t]) - 46
 			x:+5
@@ -589,7 +589,7 @@ Type AStarDemo
 '		nodeMap = Array:AStarNode[mapWidth, mapHeight]
 
 ' Initialise terrain types
-		Local t
+		Local t:Int
 		For t = 0 To numTerrainTypes - 1
 			Local newTerrain:Terrain = New Terrain
 			newTerrain.set(terrainWeights[t], terrainFilenames[t])
@@ -606,8 +606,8 @@ Type AStarDemo
 		
 ' Initialise the map
 		SeedRnd MilliSecs()
-		Local y
-		Local x
+		Local y:Int
+		Local x:Int
 		For y = 0 To mapHeight - 1
 			For x = 0 To mapWidth - 1
 				Local value:Int = 0'Rand(0,numTerrainTypes - 1)
@@ -623,7 +623,7 @@ Type AStarDemo
 
 ' This runs AStar with the current setup
 
-	Method runAStar()
+	Method runAStar:Int()
 
 ' The first thing you need to do before using the AStarGraphWalker is to create your nodes, and link them up
 ' with edges. What I do is first make an array of the nodes, this makes it easy to map nodes to map blocks if
@@ -665,10 +665,10 @@ Type AStarDemo
 				Local node:AStarNode = nodeMap[x,y]
 ' Now look around the map for neighbours and make nodes 
 ' Joining the current one with a neighbour
-				Local off = 0
+				Local off:Int = 0
 				While off < offsetCount
-					Local neighbourX = x + xOffset[off]
-					Local neighbourY = y + yOffset[off]		
+					Local neighbourX:Int = x + xOffset[off]
+					Local neighbourY:Int = y + yOffset[off]		
 ' Check that the neighbour position is within the map bounds and is actually
 ' not block 1 which I've designated as a block we can't go through at all so no point
 ' making a neighbour of it
@@ -767,7 +767,7 @@ Type WalkerCallback Extends AStarCallback
 			For y = 0 To _application.mapHeight - 1
 				For x = 0 To _application.mapWidth - 1
 					Local node:AStarNode = _application.nodeMap[x,y]
-					Local col_r=128,col_g=128,col_b=128
+					Local col_r:Int=128,col_g:Int=128,col_b:Int=128
 					Local do:Int = 0;
 					If node.inClosed() Or Not node.inOpen() Then 
 						Continue

+ 16 - 15
samples/aaronkoolen/AStar/astar_graph_walker.bmx

@@ -1,3 +1,4 @@
+SuperStrict
 ' Class for walking an astar graph
 ' It's up to you to make the graph yourself.
 
@@ -148,7 +149,7 @@ Type AStarGraphWalker
 ' False - Failed to find path to the end node
 ' True 	- Found a path to the end
 ' PRE: Must have called setParameters first
-	Method walk()
+	Method walk:Int()
 		Assert _parametersSet,"Must call setParameters() first"
 
 		_lastWalkSucceeded = False
@@ -206,12 +207,12 @@ Type AStarGraphWalker
 
 ' Returns an estimated distance between two nodes
 	Method _distanceTo:Float(startNode:AStarNode, endNode:AStarNode)
-		Local startX = startNode._x
-		Local startY = startNode._y
-		Local endX = endNode._x
-		Local endY = endNode._y
-		Local dx = Abs(endX - startX)
-		Local dy = Abs(endY - startY)
+		Local startX:Int = startNode._x
+		Local startY:Int = startNode._y
+		Local endX:Int = endNode._x
+		Local endY:Int = endNode._y
+		Local dx:Int = Abs(endX - startX)
+		Local dy:Int = Abs(endY - startY)
 'TODO: I had distanceFunction without the _ below and Blitz Didn't complain
 		Select _distanceFunction
 			Case distanceEuclidean
@@ -240,20 +241,20 @@ Type AStarGraphWalker
 ' Then distanceEuclidean is a good estimator of distance and distancePseudoEuclidean
 ' tends to override the edgecosts and the pathfinder sort of busts through them. 
 ' This can be a good thing as it could provide a simple way to make a unit "dumber"
-	Const distanceEuclidean = 0
-	Const distancePseudoEuclidean = 1
-	Const distanceManhatten = 2
-	Const distanceDiagonalShortcut = 3
+	Const distanceEuclidean:Int = 0
+	Const distancePseudoEuclidean:Int = 1
+	Const distanceManhatten:Int = 2
+	Const distanceDiagonalShortcut:Int = 3
 
-	Field _heuristicMultiplier = 1			' 0 should generate "optimal" path
+	Field _heuristicMultiplier:Int = 1			' 0 should generate "optimal" path
 	Field _start:AStarNode
 	Field _end:AStarNode
 	Field _distanceMode:Int = distanceEuclidean
 	Field _queue:PriorityQueue
-	Field _parametersSet = False
+	Field _parametersSet:Int = False
 	Field _finalPath:TList
 	Field _callback:AStarCallback = Null
-	Field _distanceFunction = distanceEuclidean
-	Field _lastWalkSucceeded = False
+	Field _distanceFunction:Int = distanceEuclidean
+	Field _lastWalkSucceeded:Int = False
 
 EndType

+ 1 - 5
samples/birdie/misc/filmclip/main.bmx

@@ -1,10 +1,6 @@
 Strict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2D
 Import brl.Random
 Import brl.pngloader
 

+ 1 - 5
samples/birdie/misc/lightImage/main.bmx

@@ -3,11 +3,7 @@
 '
 Strict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2D
 Import brl.pngloader
 Import brl.ramstream
 

+ 2 - 5
samples/digesteroids/digesteroids.bmx

@@ -18,16 +18,13 @@
 	
 Strict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2D
 Import brl.pngloader
 Import brl.wavloader
 Import brl.oggloader
 Import brl.Random
 Import sdl.sdlfreeaudio
+Import Brl.StandardIO 'for debuglog()
 
 ' Import various utilities.
 Import "simplephysics.bmx"

+ 6 - 6
samples/flameduck/circlemania/cmania.bmx

@@ -69,7 +69,7 @@ Type circleBob
 		x:+Cos(velocity.angle)*velocity.length
 		y:+Sin(velocity.angle)*velocity.length*yaspect
 		life:-1
-		SetAlpha life/40
+		SetAlpha life/40:Double
 		DrawImage cmBob, Float(x), Float(y)
 	End Method
 
@@ -195,7 +195,7 @@ End Type
 
 Graphics 800,600,0
 
-Global yaspect:Double = 3/5!
+Global yaspect:Double = 3/5.0
 Global rastaImage:TImage = LoadImage("rasta.png")
 Global logo:TImage = LoadImage("cmanialogo.png")
 Global cmBob:TImage = LoadImage("circlebob.png")
@@ -204,9 +204,9 @@ MidHandleImage logo
 Global maskEffect:imageStrip = imageStrip.LoadImages("anim")
 
 Local myRBList:TList = New TList
-rasterBar.addRasterBar(3!,2!, [255,0,0], myRBList)
-rasterBar.addRasterBar(5!,1.5!, [0,255,0], myRBList)
-rasterBar.addRasterBar(7!,1!, [0,0,255], myRBList)
+rasterBar.addRasterBar(3,2.0, [255,0,0], myRBList)
+rasterBar.addRasterBar(5,1.5, [0,255,0], myRBList)
+rasterBar.addRasterBar(7,1, [0,0,255], myRBList)
 
 Local angle:Double = 0
 Local effectRoot:root = root.Create(4, 200, 6, 6)
@@ -218,7 +218,7 @@ While Not KeyHit(KEY_ESCAPE)
 	Local xpos:Int = 124 * Sin(angle)
 
 	For Local i:rasterBar = EachIn myRBList
-		i.drawRasterBar(xpos+32 , 28, 28)
+		i.drawRasterBar(xpos+32 , 28, 28:Double)
 	Next
 
 	SetBlend ALPHABLEND

+ 1 - 5
samples/hitoro/debugprintq.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2d
 
 ' Debug Print Queue...
 

+ 1 - 5
samples/hitoro/fireworks.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2d
 Import brl.Random
 
 ' Global variables tracking number of Firework objects and

+ 2 - 6
samples/hitoro/shadowimage.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2d
 Import brl.pngloader
 Import brl.Random
 
@@ -60,7 +56,7 @@ Repeat
 
         SetScale scale, scale
 	SetRotation 0
-	TileImage grass
+	TileImage(grass,0,0)
 
 	For Local loop:Int = 0 To NUM - 1
 

+ 1 - 5
samples/hitoro/singlelist.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2d
 Import brl.linkedlist
 Import brl.Random
 

+ 1 - 5
samples/hitoro/throwrockets.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2d
 Import brl.pngloader
 Import brl.ramstream
 Import brl.linkedlist

+ 2 - 6
samples/hitoro/tilerocket.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2d
 Import brl.pngloader
 Import brl.Random
 
@@ -99,7 +95,7 @@ Repeat
 	Cls
 	
 	SetBlend SOLIDBLEND
-	TileImage sky
+	TileImage(sky, 0,0)
 
 	Local ang# = ATan2 (my - GH2, mx - GW2)
 

+ 1 - 5
samples/hitoro/viewport.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2d
 Import brl.pngloader
 Import brl.ramstream
 

+ 2 - 6
samples/simonh/fireworks/fireworks.bmx

@@ -2,11 +2,7 @@
 
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2D
 Import brl.pngloader
 Import brl.Random
 
@@ -96,7 +92,7 @@ While Not KeyHit(KEY_ESCAPE)
 
 			sp.alpha=sp.alpha-0.01
 
-			SetColor Int(sp.r),Int(sp.g),Int(sp.b)
+			SetColor int(sp.r),int(sp.g),int(sp.b)
 			SetBlend LIGHTBLEND
 			SetAlpha sp.alpha
 			SetScale 20/sp.z,20/sp.z

+ 1 - 5
samples/simonh/snow/snowfall.bmx

@@ -2,11 +2,7 @@
 
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2D
 Import brl.pngloader
 Import brl.Random
 

+ 2 - 6
samples/spintext/spintext.bmx

@@ -1,10 +1,6 @@
 SuperStrict
 
-?win32
-Framework SDL.d3d9sdlmax2d
-?Not win32
-Framework SDL.gl2sdlmax2d
-?
+Framework SDL.SDLRenderMax2D
 
 Graphics 640,480, 0
 
@@ -35,4 +31,4 @@ While Not KeyHit( KEY_ESCAPE )
 	Flip
 
 Wend
-	
+