Giter Club home page Giter Club logo

triptych / wonkey Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wonkey-coders/wonkey

0.0 1.0 0.0 107.47 MB

Wonkey is an open source programming language for the creation of cross-platform video games.

Home Page: https://wonkey-coders.github.io/

License: zlib License

Makefile 2.42% Perl 1.24% Python 18.66% Shell 1.15% CSS 0.29% Ragel 3.32% Objective-C++ 1.09% GLSL 1.01% HTML 5.75% CMake 5.44% Objective-C 18.20% M4 1.13% Metal 0.10% Assembly 20.71% Batchfile 0.12% Lua 0.03% C++ 1.24% C# 5.65% Awk 0.02% Roff 12.43%

wonkey's Introduction

Views Travis CI windows linux macos raspbian

Wonkey Programming Language

Wonkey is an open source programming language for the creation of cross-platform video games, highly inspired by the “Blitz” range of languages.

Desktop targets

Windows MacOS Linux Raspbian

Mobile targets

Android iOS

Web targets

Emscripten

More information

Website: https://wonkey-coders.github.io/

Github page: https://github.com/wonkey-coders

Discord channel : https://discord.gg/awfuRtZay7

Join the community and improve this programming language.

Enjoy!

Showcase

Wonkey on Raspbian (Raspberry PI 4)

Click screenshots to run the examples in browser:

Pool

Toy plane

Commanche


How to build from source

Table of contents

If you are reading this on Github, please note there are prebuilt versions of wonkey (with complete source code) available from https://github.com/wonkey-coders/wonkey/releases.

Building on Windows

Using GCC

Unless you are using one of the prebuilt releases, you will need to install the mingw-64 compiler. There are self-extracting archive of mingw-64 that has been tested with wonkey here :

If you install this to the wonkey 'devtools' directory, the following steps should 'just work' (ha!) else you must added mingw64\bin path in your environment variables.

NOTE: Wonkey use x64 by default. See bin\windows\env_windows.txt file for more information.

Using MSVC

Wonkey auto-detected your MSVC installation and use it by default, no need to changes anymore. If you want using GCC, you need to change WX_USE_MSVC variable in bin\windows\env_windows.txt.

Follow the next steps to build :

  1. Open a command prompt and change to the 'wonkey\scripts' directory.
  2. Enter rebuildall.bat and hit return. Wait...
  3. If all went well, you should end up with a 'Wonkey (windows)' exe in the wonkey directory. Run this to launch the WIDE (Wonkey IDE).
  4. You should now be able to build and run wonkey apps. There are some sample apps in the 'wonkey/examples' directory.

Building on MacOS/Linux

  • On MacOS, install the XCode command line tools. You can do this by entering in a shell :
xcode-select --install
  • On Linux, install the GCC toolchain and libraries. You can do this by entering in a shell :
sudo apt-get install g++-multilib libopenal-dev libpulse-dev libsdl2-dev

Follow the next steps to build :

  1. Open a shell and change to the 'wonkey/scripts' directory.
  2. Enter ./rebuildall.sh and hit return. Wait...
  3. If all went well, you should end up with a 'Wonkey (...)' app in the wonkey directory. Run this to launch the WIDE (Wonkey IDE).
  4. You should now be able to build and run wonkey apps. There are some sample apps in the 'wonkey/examples' directory.

Setup Emscripten target

See installation instructions from Emscripten site.

# Get the emsdk repo
git clone https://github.com/emscripten-core/emsdk.git

# Enter that directory
cd emsdk

# Fetch the latest version of the emsdk (not needed the first time you clone)
git pull

# Download and install the latest SDK tools.
./emsdk install latest

# Make the "latest" SDK "active" for the current user. (writes .emscripten file)
./emsdk activate latest

# Activate PATH and other environment variables in the current terminal
source ./emsdk_env.sh

#In the description above we asked the emsdk to install and activate latest, which is the latest tagged release. That is often what you want.

# You can also install a specific version by specifying it, for example,
./emsdk install 1.38.45

NOTE: on macOS, you can use brew install emscripten.

NOTE: on Windows, run emsdk instead of ./emsdk, and emsdk_env.bat instead of source ./emsdk_env.sh.


Introduction to Wonkey

ℹ️ More complete help and samples are available online at https://wonkey-coders.github.io/.

"Hello, Wonkey!'

Function Main()
	Print "Hello, Wonkey!"
End

While staying true to the 'basic' style of the original Blitz languages, Wonkey offers some very powerful new features including:

Generic classes and methods

Classes, interfaces, structs, methods and functions can have 'type' parameters.

Struct Rect<T>
	Field x0:T, y0:T
	Field x1:T, y1:T
End

'Main entry
Function Main()
	Local r:=New Rect<Float>
End

'First class' functions

Functions (and methods) can be stored in variables and passed to/from other functions.

Function Test1()
	Print "Test1"
End

Function Test2()
	Print "Test2"
End

Function Tester( test:Void() )
	test()
End

'Main entry
Function Main()
	Tester( Test1 )
	Tester( Test2 )
End

Lambda functions

Lambda functions allow you to create closures.

Function Test( func:Void() )
	func()
End

'Main entry
Function Main()
	For Local i:=0 Until 10
		Test( Lambda()
			Print i
		End)
	Next
End

New 'Struct' type that provides value semantics

Structs are similar to classes in that they encapsulate member data, but differ in that they are passed around 'by value' instead of 'by reference'.

This allows structs to be efficiently create on the stack without any garbage collection overhead.

Struct S
	Field data:Int=10
End

Function Test( s:S )
	s.data = 100
End

'Main entry
Function Main()
	Local s:=New S 'Create a new S on the stack (very fast!)
	Test( s )      'Test gets a copy of 's'
	Print s.data   'Print '10'
End

Fibers for easy asynchronous programming

Fibers provide support for 'cooperative' multi-threading.

Function Server( host:String, service:String )
	Local server:=Socket.Listen( host, service )
	
	Repeat
		Local client:=server.Accept()
		New Fiber( Lambda()
			Local data:=client.Receive(...)
		End )
	Forever
End

Operator overloading

Operator overloading allows you to override the meaning of the built-in language operators, making for more expressive code.

Struct Vec2
	Field x:Float
	Field y:Float

	Method New( x:float,y:Float )
		Self.x=x
		Self.y=y
	End

	Operator+:Vec2( v:Vec2 )
		Return New Vec2( x+v.x,y+v.y )
	End

	Operator To:String()
		Return "Vec2("+x+","+y+")"
	End
End

'Main entry
Function Main()
	Local v0:=New Vec2( 10,20 )
	Local v1:=New Vec2( 30,40 )
   
	Print v0+v1
End

Class extensions

Class extensions allow you to add extra methods, functions and properties to existing classes.

Struct Foo
	Field i:Int=0
End 
Struct Foo Extension
	Method Increment()
		i+=1
	End
End

Fully garbage collected

Wonkey provides a 'mostly' incremental garbage collector that efficiently collects garbage as it runs without any of those annoying 'sweep' spikes found in typical garbage collectors.

Optional reflection features

Wonkey includes an optional reflection system that allows you to inspect and modify variables and values at runtime:

#Import "<reflection>"

Class C
	Method Update( msg:String )
		Print "C.Update : msg=" + msg
	End
End

'Main entry
Function Main()
	Local c:=New C
	
	Local type:=Typeof( c )
	Print type
	
	Local decl:=type.GetDecl( "Update" )
	decl.Invoke( c, "Hello World!" )
End

Credits

Wonkey is an community project and an fork of Monkey2 programming language designed by Mark Sibly, creator of the 'Blitz' range of languages.

wonkey's People

Contributors

abakobo avatar d-a-n-i-l-o avatar seyhajin avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.