Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add .wx extension to Monkey language #5964

Closed
wants to merge 11 commits into from
1 change: 1 addition & 0 deletions lib/linguist/languages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4309,6 +4309,7 @@ Monkey:
extensions:
- ".monkey"
- ".monkey2"
- ".wx"
ace_mode: text
tm_scope: source.monkey
language_id: 236
Expand Down
107 changes: 107 additions & 0 deletions samples/Monkey/effects.wx
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
Namespace myapp

#Import "<std>"
#Import "<mojo>"
#Import "<mojo3d>"

#Import "assets/"

Using std..
Using mojo..
Using mojo3d..

Class MyWindow Extends Window

Field _scene:Scene

Field _camera:Camera

Field _light:Light

Field _donut:Model

Field _bloom:BloomEffect

Field _mono:MonochromeEffect

Field _godrays:GodraysEffect

Field _fxaa:FXAAEffect

Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable|WindowFlags.HighDPI )

Super.New( title,width,height,flags )

_scene=Scene.GetCurrent()
_scene.ClearColor=Color.Sky

'create camera
'
_camera=New Camera( self )
_camera.Move( 0,10,-10 )
New FlyBehaviour( _camera )

'create light
'
_light=New Light
_light.Rotate( 120,0,0 )

'create effects
'
_godrays=New GodraysEffect
_godrays.Enabled=false
_godrays.Light=_light

_bloom=New BloomEffect
_bloom.Enabled=False

_mono=New MonochromeEffect
_mono.Enabled=False

_fxaa=New FXAAEffect
_fxaa.Enabled=False

_scene.AddPostEffect( _bloom )
_scene.AddPostEffect( _mono )
_scene.AddPostEffect( _godrays )
_scene.AddPostEffect( _fxaa )

Local material:=New PbrMaterial( New Color( 2,.5,0,1 ),0,1 )

_donut=Model.CreateTorus( 2,.5,48,24,material )
_donut.AddComponent<RotateBehaviour>().Speed=New Vec3f( .1,.2,.3 )

_donut.Move( 0,10,0 )
End

Method OnRender( canvas:Canvas ) Override

RequestRender()

If Keyboard.KeyHit( Key.Key1 ) _godrays.Enabled=Not _godrays.Enabled
If Keyboard.KeyHit( Key.Key2 ) _bloom.Enabled=Not _bloom.Enabled
If Keyboard.KeyHit( Key.Key3 ) _mono.Enabled=Not _mono.Enabled
If Keyboard.KeyHit( Key.Key4 ) _fxaa.Enabled=Not _fxaa.Enabled

_scene.Update()

_scene.Render( canvas )

canvas.DrawText( "(1) Godrays="+_godrays.Enabled,0,0 )
canvas.DrawText( "(2) Bloom="+_bloom.Enabled,0,16 )
canvas.DrawText( "(3) Monochrome="+_mono.Enabled,0,32 )
canvas.DrawText( "(4) FXAA="+_fxaa.Enabled,0,48 )
End

End

Function Main()

' SetConfig( "MOJO_OPENGL_PROFILE","es" )

New AppInstance

New MyWindow

App.Run()
End
96 changes: 96 additions & 0 deletions samples/Monkey/mojotest.wx
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@

#Import "<std>"
#Import "<mojo>"

#Import "assets/RedbrushAlpha.png"

Namespace mojotest

Using std..
Using mojo..

Class MojoTest Extends Window

Field image:Image

Field tx:Float,ty:Float
Field r:Float=1,g:Float=1,b:Float=1

Method New()

ClearColor=New Color( 0,0,.5 )

image=Image.Load( "asset::RedbrushAlpha.png" )
image.Handle=New Vec2f( .5,.5 )
End

Method OnRender( canvas:Canvas ) Override

App.RequestRender()

Local sz:=Sin( Millisecs()*.0007 ) * 32
Local sx:=32+sz,sy:=32,sw:=Width-(64+sz*2),sh:=Height-(64+sz)

canvas.Scissor=New Recti( sx,sy,sx+sw,sy+sh )
canvas.Clear( New Color( 1,32.0/255.0,0,1 ) )

canvas.PushMatrix()

canvas.Translate( tx,ty )
canvas.Scale( Width/640.0,Height/480.0 )
canvas.Translate( 320,240 )
canvas.Rotate( Millisecs()*.0003 )
canvas.Translate( -320,-240 )

canvas.Color=New Color( .5,1,0 )
canvas.DrawRect( 32,32,640-64,480-64 )

canvas.Color=Color.Yellow
For Local y:=0 Until 480
For Local x:=16 Until 640 Step 32
canvas.Alpha=Min( Abs( y-240.0 )/120.0,1.0 )
canvas.DrawPoint( x,y )
Next
Next
canvas.Alpha=1

canvas.Color=New Color( 0,.5,1 )
canvas.DrawOval( 320,240,320-64,240-64 )

canvas.Color=New Color( 1,0,.5 )
canvas.DrawLine( 32,32,640-32,480-32 )
canvas.DrawLine( 640-32,32,32,480-32 )

canvas.Color=New Color( r,g,b,Sin( Millisecs()*.003 ) *.5 +.5 )
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 ) )

canvas.Color=New Color( 1,.5,0 )
canvas.DrawText( "The Quick Brown Fox Jumps Over The Lazy Dog",320,240,.5,.5 )

canvas.PopMatrix()

canvas.Scissor=Rect
canvas.Color=Color.Red
canvas.DrawRect( 0,0,Width,1 )
canvas.DrawRect( Width-1,0,1,Height )
canvas.DrawRect( 0,Height-1,Width,1 )
canvas.DrawRect( 0,0,1,Height-1 )

canvas.Color=Color.Blue

End

End

Function Main()

New AppInstance

New MojoTest

App.Run()

End
100 changes: 100 additions & 0 deletions samples/Monkey/particles.wx
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
Namespace myapp

#Import "<std>"
#Import "<mojo>"
#Import "<mojo3d>"

Using std..
Using mojo..
Using mojo3d..

Class MyWindow Extends Window

Field _scene:Scene

Field _camera:Camera

Field _light:Light

Field _ground:Model

Field _particles:ParticleSystem

Method New( title:String="Simple mojo app",width:Int=640,height:Int=480,flags:WindowFlags=WindowFlags.Resizable|WindowFlags.HighDPI )

Super.New( title,width,height,flags )

_scene=Scene.GetCurrent()

' _scene.SkyTexture=Texture.Load( "asset::miramar-skybox.jpg",TextureFlags.FilterMipmap|TextureFlags.Cubemap )

_scene.FogColor=Color.Sky
_scene.FogNear=20
_scene.FogFar=1000

'create camera
'
_camera=New Camera( Self )
_camera.Near=.01
_camera.Move( 0,1,-1 )
New FlyBehaviour( _camera )

'create light
'
_light=New Light
_light.Rotate( 60,45,0 ) 'aim directional light 'down' - Pi/2=90 degrees.

'create ground
'
_ground=Model.CreateBox( New Boxf( -50,-1,-50,50,0,50 ),1,1,1,New PbrMaterial( Color.Green * .5 ) )

_particles=New ParticleSystem( 15000 )
_particles.RotateX( -90 ) 'point upwards!

Local pmaterial:=_particles.Material
' pmaterial.ColorTexture=Texture.Load( "asset::bluspark.png",TextureFlags.FilterMipmap )

Local pbuffer:=_particles.ParticleBuffer
pbuffer.Gravity=New Vec3f( 0,-9.81,0 ) 'gravity in world space in m/s^2.
pbuffer.Duration=2.5 'how long a single particle lasts in seconds.
pbuffer.Fade=0.0 'how long before paticle starts fading out in seconds.
pbuffer.Colors=New Color[]( Color.White,Color.Yellow,Color.Orange,Color.Red )
pbuffer.ConeAngle=30 'angle of particle emission cone.
pbuffer.MinVelocity=15.0 'min particle velocity.
pbuffer.MaxVelocity=20.0 'max particle velocity.
pbuffer.MinSize=8.0 'min particle size.
pbuffer.MaxSize=12.0 'max particle size.

For Local an:=0 Until 360 Step 45

Local pivot:=New Pivot
pivot.RotateY( an )
pivot.MoveZ( 20 )
pivot.Visible=True

_particles.Copy( pivot )
Next

End

Method OnRender( canvas:Canvas ) Override

RequestRender()

_scene.Update()

_scene.Render( canvas )

canvas.DrawText( "Width="+Width+", Height="+Height+", FPS="+App.FPS,0,0 )
End

End

Function Main()

New AppInstance

New MyWindow

App.Run()
End
Loading