Skip to content

Commit

Permalink
Merge pull request #92 from blitz-research/develop
Browse files Browse the repository at this point in the history
dev up
  • Loading branch information
abakobo committed Nov 28, 2017
2 parents 9ba5ed6 + 9bf2154 commit 6ad4671
Show file tree
Hide file tree
Showing 64 changed files with 1,612 additions and 601 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -33,6 +33,7 @@ __NEWPAGES__/
/src/ted2go-v*
/src/ted2go-dev
/src/ted2go-master
/src/ted2go-github

/modules/cmark
/modules/lua
Expand Down
4 changes: 2 additions & 2 deletions VERSIONS.TXT
@@ -1,9 +1,9 @@

***** Monkey2 v1.1.09 *****

Added experimental selective reflection.
Added SDL GameController class. Tweaked Joystick/GameController Open logic so devices can be added/removed more cleanly. See joystick and gamecontroller samples in bananas.

Use '#Reflect namepsace_path' to enable reflection for an entire namespace. Using same system as 'Using' ie: can end with '..' to 'reflect all'.
Added experimental selective reflection. Use '#Reflect namepsace_path' to enable reflection for an entire namespace. Using same system as 'Using' ie: can end with '..' to 'reflect all'.


***** Monkey2 v1.1.08 *****
Expand Down
Binary file added bananas/bunnymark/assets/wabbit_alpha.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
152 changes: 152 additions & 0 deletions bananas/bunnymark/bunnymark.monkey2
@@ -0,0 +1,152 @@
Namespace bunnies

#Import "assets/wabbit_alpha.png"

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

Using std..
Using mojo..

Global VirtualSize:=New Vec2i( 640,480 )

Const initialCount := 10000

Function Main()
New AppInstance
New Bunnymark
App.Run()
End Function

'******************************************************************************************************

Class Bunnymark Extends Window

Field atlas:Image

Field frames:=New Image[4]

Field bunnies := New Stack<Bunny>

Method New()
Super.New("Bunnymark", 1024, 768, WindowFlags.Resizable )

Layout="letterbox"

atlas=Image.Load( "asset::wabbit_alpha.png" )

For Local j:=0 Until 2
For Local i:=0 Until 2
frames[ j*2+i ]=New Image( atlas,i*32,j*64,32,64 )
frames[ j*2+i ].Handle=New Vec2f( .5,.5 )
Next
Next

For Local n:= 0 Until initialCount
bunnies.Push( New Bunny( 512, 384,frames[ Rnd(4) ] ) )
Next
End

Method OnMeasure:Vec2i() Override

Return VirtualSize
End

Method OnRender( canvas:Canvas ) Override

RequestRender()

If Keyboard.KeyReleased(Key.Escape) Then App.Terminate()

canvas.Color = Color.White
canvas.DrawRect( 0, 0, App.ActiveWindow.Width , 25 )

For Local bunny:=Eachin bunnies
bunny.Update( canvas )
Next

canvas.Color = Color.Black
canvas.DrawText( "Bunnymark="+bunnies.Length+" FPS="+App.FPS+" (LMB=+10 MMB=+100 RMB=+1000 +Alt=Remove)",10,5 )

End

Method OnMouseEvent( event:MouseEvent ) Override

If event.Type = EventType.MouseDown
Local _len := 0
If event.Button = MouseButton.Left
_len = 10
Elseif event.Button = MouseButton.Middle
_len = 100
Elseif event.Button = MouseButton.Right
_len = 1000
End

If Keyboard.KeyDown( Key.LeftAlt ) Or Keyboard.KeyDown( Key.RightAlt )
For Local n := 1 To _len
If bunnies.Length Then bunnies.Pop()
Next
Else
For Local n := 1 To _len
bunnies.Push( New Bunny( Mouse.X, Mouse.Y,frames[ Rnd(4) ] ) )
Next
End
End

End

End


'******************************************************************************************************


Class Bunny

Global gravity := 0.1
Global border := 32.0

Field x: Float
Field y: Float
Field xspeed: Float
Field yspeed: Float
Field maxBounce:= 5.0

Field image:Image

Method New( x:Float,y:Float,image:Image )
Self.x = x
Self.y = y

xspeed = Rnd( -10, 10 )

Self.image=image
End


Method Update:Void( canvas:Canvas )
yspeed += gravity

y += yspeed
x += xspeed

If y < border*2
y = border*2
yspeed *= -1
yspeed = Clamp( yspeed, 0.0, Float( maxBounce ) )
End

If y > App.ActiveWindow.Height - border
y = App.ActiveWindow.Height - border
yspeed = -random.Rnd( maxBounce * 3 )
End

If( x < border ) Or ( x > App.ActiveWindow.Width - border )
xspeed *= -1
x = Clamp( x, border, Float(App.ActiveWindow.Width - border ) )
End

canvas.DrawImage( image,x,y )
End

End
13 changes: 9 additions & 4 deletions bin/env_windows.txt
Expand Up @@ -3,6 +3,11 @@
'
MX2_WHOLE_ARCHIVE=0

'Semi-colon separated list of module root dirs, relative to MX2_HOME or absolute.
'
'mx2cc always adds local modules/ dir to start of list.
'
'MX2_MODULE_DIRS=modules;modules_ext

'If you change anything below, you should rebuild all!

Expand Down Expand Up @@ -52,14 +57,14 @@ MX2_LD_OPTS_MSVC=
MX2_LD_OPTS_MSVC_DEBUG=
MX2_LD_OPTS_MSVC_RELEASE=

MX2_CC_OPTS_MSVC=-EHs -W0 -MT
MX2_CC_OPTS_MSVC=-EHs -W0 -MT -utf-8
MX2_CC_OPTS_MSVC_DEBUG=-O1
MX2_CC_OPTS_MSVC_RELEASE=-Ox -DNDEBUG
MX2_CC_OPTS_MSVC_RELEASE=-O2 -DNDEBUG

'C++ Compiler options
MX2_CPP_OPTS_MSVC=-EHs -W0 -MT
MX2_CPP_OPTS_MSVC=-EHs -W0 -MT -utf-8
MX2_CPP_OPTS_MSVC_DEBUG=-O1
MX2_CPP_OPTS_MSVC_RELEASE=-Ox -DNDEBUG
MX2_CPP_OPTS_MSVC_RELEASE=-O2 -DNDEBUG


'***** EMSCRIPTEN/WASM *****
Expand Down
2 changes: 2 additions & 0 deletions modules/assimp/assimp.monkey2
Expand Up @@ -146,6 +146,8 @@ End

Class aiAnimation Extends Void

Field mName:aiString

Field mDuration:Double

Field mTicksPerSecond:Double
Expand Down
40 changes: 21 additions & 19 deletions modules/libc/libc.monkey2
Expand Up @@ -94,7 +94,7 @@ Const SEEK_SET:Int
Const SEEK_CUR:Int
Const SEEK_END:Int

Function fopen:FILE Ptr( path:CString,mode:CString )
Function fopen:FILE Ptr( path:CString,mode:CString )="fopen_utf8"

Function rewind:Void( stream:FILE )
Function ftell:Int( stream:FILE Ptr )
Expand All @@ -104,29 +104,31 @@ Function fread:Int( buf:Void Ptr,size:Int,count:Int,stream:FILE Ptr )
Function fwrite:Int( buf:Void Ptr,size:Int,count:Int,stream:FILE Ptr )
Function fflush:Int( stream:FILE Ptr )
Function fclose:Int( stream:FILE Ptr )
Function fputs:Int( str:CString,stream:FILE Ptr )
Function fputs:Int( str:CString,stream:FILE Ptr )="fputs_utf8"

Function remove:Int( path:CString )
Function rename:Int( oldPath:CString,newPath:CString )
Function remove:Int( path:CString )="remove_utf8"
Function rename:Int( oldPath:CString,newPath:CString )="rename_utf8"

Function puts:Int( str:CString )
Function puts:Int( str:CString )="puts_utf8"

'***** stdlib.h *****

Function malloc:Void Ptr( size:Int )
Function free:Void( mem:Void Ptr )


#If __TARGET__<>"ios" 'gone in ios11!
Function system:Int( cmd:CString )="system_"
Function system:Int( cmd:CString )="system_utf8"
#endif
Function setenv:Int( name:CString,value:CString,overwrite:Int )="setenv_"
Function getenv:char_t ptr( name:CString )

Function setenv:Int( name:CString,value:CString,overwrite:Int )="setenv_utf8"
Function getenv:char_t Ptr( name:CString )="getenv_utf8"

Function exit_:Void( status:Int )="exit"
Function atexit:Int( func:Void() )="atexit"
Function abort:Void()

Function realpath:char_t Ptr( path:CString,resolved_path:char_t Ptr )
Function realpath:char_t Ptr( path:CString,resolved_path:char_t Ptr )="realpath_utf8"

'***** string.h *****

Expand Down Expand Up @@ -172,13 +174,13 @@ Function time:time_t( timer:time_t Ptr )
Function localtime:tm_t Ptr( timer:time_t Ptr )
Function gmtime:tm_t Ptr( timer:time_t Ptr )
Function difftime:Double( endtime:time_t,starttime:time_t )
Function gettimeofday:Int( tv:timeval Ptr )="gettimeofday_"
Function gettimeofday:Int( tv:timeval Ptr )="gettimeofday_utf8"

'***** unistd.h *****

Function getcwd:char_t Ptr( buf:char_t Ptr,size:Int )
Function chdir:Int( path:CString )
Function rmdir:Int( path:CString )
Function getcwd:char_t Ptr( buf:char_t Ptr,size:Int )="getcwd_utf8"
Function chdir:Int( path:CString )="chdir_utf8"
Function rmdir:Int( path:CString )="rmdir_utf8"

'***** sys/stat.h *****

Expand All @@ -200,18 +202,18 @@ Struct stat_t
Field st_ctime:time_t 'status change
End

Function stat:Int( path:CString,buf:stat_t Ptr )
Function mkdir:Int( path:CString,mode:Int )="mkdir_"
Function stat:Int( path:CString,buf:stat_t Ptr )="stat_utf8"
Function mkdir:Int( path:CString,mode:Int )="mkdir_utf8"

'***** dirent.h *****

Struct DIR
End

Struct dirent
Field d_name:Void Ptr
Field d_name:CString
End

Function opendir:DIR Ptr( path:CString )
Function readdir:dirent Ptr( dir:DIR Ptr )
Function closedir( dir:DIR Ptr )
Function opendir:DIR Ptr( path:CString )="opendir_utf8"
Function readdir:dirent Ptr( dir:DIR Ptr )="readdir_utf8"
Function closedir( dir:DIR Ptr )="closedir_utf8"

0 comments on commit 6ad4671

Please sign in to comment.