فهرست منبع

Tweaked bananas.

Mark Sibly 9 سال پیش
والد
کامیت
2dd572396d

+ 0 - 13
modules/mojo/bananas/commanche/commanche.monkey2

@@ -61,8 +61,6 @@ Class MyWindow Extends Window
 		Print "in Loadmap"	
 		Dmap = Pixmap.Load("asset::D1.png",PixelFormat.RGBA32)
 		Cmap = Pixmap.Load("asset::C1W.png",PixelFormat.RGBA32)
-		'Dmap = Dmap.Convert(PixelFormat.RGBA32)'crash
-		'Cmap = Cmap.Convert(PixelFormat.RGBA32)
 		
 		If Not Dmap Then Print "no Dmap!"
 		If Not Cmap Then Print "no Cmap!"
@@ -139,17 +137,6 @@ Class MyWindow Extends Window
 			Endif
 		Next
 	End Method
-	'-----------------------------------------------------------------------------------------------------------
-	Method OnKeyEvent( event:KeyEvent ) Override
-	
-		Select event.Type
-		Case EventType.KeyDown,EventType.KeyUp
-			Print Keyboard.KeyName( event.Key )
-			Print Int( event.Modifiers )
-			Print Int( Keyboard.Modifiers )
-		End
-		
-	End
 End
 '-----------------------------------------------------------------------------------------------------------
 Function Main()

+ 1 - 0
modules/mojo/bananas/life/life.monkey2

@@ -1,3 +1,4 @@
+
 'An implementation of Conway's Game of Life
 
 'http://en.wikipedia.org/wiki/Conway's_Game_of_Life

+ 5 - 6
modules/mojo/bananas/mojotest/mojotest.monkey2

@@ -19,7 +19,7 @@ Class MojoTest Extends Window
 	Method New()
 		
 		ClearColor=New Color( 0,0,.5 )
-	
+
 		image=Image.Load( "asset::RedbrushAlpha.png" )
 		image.Handle=New Vec2f( .5,.5 )
 	End
@@ -55,7 +55,7 @@ Class MojoTest Extends Window
 		canvas.Alpha=1
 		
 		canvas.Color=New Color( 0,.5,1 )
-'		canvas.DrawOval( 64,64,640-128,480-128 )	'TODO!
+		canvas.DrawOval( 64,64,640-128,480-128 )
 
 		canvas.Color=New Color( 1,0,.5 )
 		canvas.DrawLine( 32,32,640-32,480-32 )
@@ -65,9 +65,9 @@ Class MojoTest Extends Window
 		canvas.DrawImage( image,320,240 )
 
 		canvas.Color=New Color( 1,0,.5 )
-'		canvas.DrawPoly( New Float[]( 140.0,232.0, 320.0,224.0, 500.0,232.0, 500.0,248.0, 320.0,256.0, 140.0,248.0 ) )	'TODO!
-				
-		canvas.Color=New Color( 1,.5,0 )'Color.Red
+		canvas.DrawPoly( New Float[]( 140.0,232.0, 320.0,224.0, 500.0,232.0, 500.0,248.0, 320.0,256.0, 140.0,248.0 ) )
+						
+		canvas.Color=New Color( 1,.5,0 )
 		canvas.DrawText( "The Quick Brown Fox Jumps Over The Lazy Dog",320,240,.5,.5 )
 		
 		canvas.PopMatrix()
@@ -80,7 +80,6 @@ Class MojoTest Extends Window
 		canvas.DrawRect( 0,0,1,Height-1 )
 
 		canvas.Color=Color.Blue
-		canvas.DrawText( Seconds(),0,0 )
 	
 	End
 

+ 1 - 0
modules/mojo/bananas/monkeyroids/monkeyroids.monkey2

@@ -1,3 +1,4 @@
+
 Namespace asteroids
 
 #Import "<std>"

+ 2 - 0
modules/mojo/bananas/rendertoimage/rendertoimage.monkey2

@@ -44,6 +44,8 @@ Class MyWindow Extends mojo.app.Window
 		icanvas.Flush()
 		
 		canvas.DrawImage( image,App.MouseLocation.x,App.MouseLocation.y )
+		
+		canvas.DrawText( "Here!",0,0 )
 	End
 	
 End

+ 33 - 13
modules/mojo/bananas/spacechimps/spacechimps.monkey2

@@ -5,7 +5,7 @@ Namespace spacechimps
 #Import "<mojo>"
 
 #Import "assets/bang.wav"
-#Import "assets/spaceship.png"
+#Import "assets/spaceship_32.png"
 
 Using std..
 Using mojo..
@@ -18,6 +18,7 @@ Class MyWindow Extends Window
 	Field pos:=New Vec2f
 	Field vel:=New Vec2f
 	Field rot:Float
+	Field filter:Bool=True
 
 	Method New( title:String,width:Int,height:Int )
 	
@@ -25,9 +26,13 @@ Class MyWindow Extends Window
 		'
 		Super.New( title,width,height,WindowFlags.Resizable )
 		
+		Layout="letterbox-int"
+		
 		'Black 'coz we're in space!
 		'
-		ClearColor=Color.Black
+		ClearColor=New Color( .03,.03,.03 )
+		
+		Style.BackgroundColor=Color.Black
 
 		'Load laser sound effecy
 		'		
@@ -39,13 +44,13 @@ Class MyWindow Extends Window
 		'
 		'Note: Scaling image here is faster than scaling in DrawImage.
 		'
-		image=Image.Load( "asset::spaceship.png" )
+		image=Image.Load( "asset::spaceship_32.png" )
 		image.Handle=New Vec2f( .5,.5 )
-		image.Scale=New Vec2f( .125,.125 )
+'		image.Scale=New Vec2f( .125,.125 )
 		
 		'Set initial image pos
 		'
-		pos=New Vec2f( width/2,height/2 )
+		pos=New Vec2f( 160,120 )
 		
 		'Start update timer
 		'
@@ -72,6 +77,8 @@ Class MyWindow Extends Window
 					timer=New Timer( 60,OnUpdate )
 				Endif
 '#Endif
+			Case Key.F
+				filter=Not filter
 			End
 		End
 	End
@@ -141,15 +148,19 @@ Class MyWindow Extends Window
 	End
 	
 	Field ms:=0
-	
+
 	Method OnRender( canvas:Canvas ) Override
-	
+
 		Local e:=App.Millisecs-ms	'ideally, e should be 16,17,17,16,17,17 ie: 16.6666...
 '		If e<>16 And e<>17 Print "elapsed="+e	'show glitches
 		ms+=e
 		
 		If Not timer OnUpdate()
 		
+		'Turn off texture filtering for a 'pixel art' look
+		'
+		canvas.FilteringEnabled=filter
+		
 		'Title text
 		'	
 		canvas.DrawText( "FPS="+App.FPS,Width/2,8,.5,0 )
@@ -160,22 +171,31 @@ Class MyWindow Extends Window
 '#Endif
 		canvas.DrawText( "Timer sync="+(timer ? "true" Else "false")+" ('T' to toggle)",Width/2,56,.5,0 )
 		canvas.Color=Color.White
+		canvas.DrawText( "Filtering="+(filter ? "true" Else "false")+" ('F' to toggle",Width/2,72,.5,0 )
 		
 		'Draw image
 		'
-		Local r:=rot-Pi/2
-		canvas.DrawImage( image,pos,r )
+		Local x:=pos.x,y:=pos.y,r:=rot-Pi/2
+		If Not filter x=Floor( x ) ; y=Floor( y )
+		
+		canvas.DrawImage( image,x,y,r )
 
 		'Draw wrap around(s)
 		'
-		If pos.x-image.Radius<0 canvas.DrawImage( image,pos.x+Width,pos.y,r )
-		If pos.x+image.Radius>Width canvas.DrawImage( image,pos.x-Width,pos.y,r )
+		If x-image.Radius<0 canvas.DrawImage( image,x+Width,y,r )
+		If x+image.Radius>Width canvas.DrawImage( image,x-Width,y,r )
 		
-		If pos.y-image.Radius<0 canvas.DrawImage( image,pos.x,pos.y+Height,r )
-		If pos.y+image.Radius>Height canvas.DrawImage( image,pos.x,pos.y-Height,r )
+		If y-image.Radius<0 canvas.DrawImage( image,x,y+Height,r )
+		If y+image.Radius>Height canvas.DrawImage( image,x,y-Height,r )
 
 	End
 	
+	Method OnMeasure:Vec2i() Override
+	
+		Return New Vec2i( 320,240 )
+		
+	End
+	
 End
 
 Function Main()

+ 1 - 1
modules/mojo/bananas/viewlayout/viewlayout.monkey2

@@ -51,7 +51,7 @@ Class MyWindow Extends Window
 		'Without it, OnRender will only be called when necessary, eg: when window is resized.
 		'
 		App.RequestRender()
-		
+
 		'Gets mouse location in 'view' coordinates.
 		'
 		Local mouse:=Mouse.Location