Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

NON - Free 2D Lua and MoonScript Game Engine


YourBestNightmare
 Share

Recommended Posts

[![](http://nondev.github.io/img/logo.png)](http://nononsense.science)

NÖN is an engine you can use to make 2D games in **[Lua](http://www.lua.org)** and **[MoonScript](http://moonscript.org)**. It's free, open-source, and works on **Windows**, **Mac OS X**, **Linux**, **Android** and **iOS**.

**Installation**
You will need to have [JDK 7+](http://www.oracle.com/technetwork/java/javase/downloads/index.html) installed. Then you can install NÖN as rock ([LuaRocks](https://luarocks.org) required)

```
luarocks install non
```**Getting Started**
* [Introduction](https://github.com/nondev/non/wiki/Introduction)
* [Create your first Non project](https://github.com/nondev/non/wiki/Getting-started)
* [Run, Manage and Package your project](https://github.com/nondev/non/wiki/Running-and-packaging-your-project)
* [Read the Wiki](https://github.com/nondev/non/wiki)

**Documentation**
The [Wiki](https://github.com/nondev/non/wiki) contains all the information you'll need to write a Non game. You can contribute to the Wiki directly on GitHub!

**Reporting Issues**
Use the [issue tracker](https://github.com/nondev/non/issues) on GitHub to report issues.
Link to comment
Share on other sites

  • Replies 146
  • Created
  • Last Reply

Top Posters In This Topic

Download:

Here is download of example nonfw project, for now you can fiddle with it, but no source code included yet: [http://ge.tt/6LCoE022/v/0](http://ge.tt/6LCoE022/v/0)

Example configuration:

```
{
"title": "No Nonsense Game",
"resolution": [800, 600],
"package": "game",
"main": "main.js",
"modules": [
"core",
"audio",
"graphics",
"input",
"math",
"tiled"
]
}

```
Example main script:

```
game.init(function() {
map = tiled.newMap("cave.tmx");
img = graphics.newImage("logo.png");
music = audio.newMusic("music.ogg");
audio.play(music);
});

game.update(function() {
// 62 is spacebar, for now not implemented easy key getting (but will do)
if (input.isKeyPressed(62))
pressed = "Key pressed: Spacebar (release Spacebar to test)";
else
pressed = "Key pressed: None (press Spacebar to test)";
});

game.draw(function() {
graphics.draw(map);
graphics.draw(img, 304, 204);
// Some testing text
graphics.draw("Author: YourBestNightmare", 10, 10, graphics.newColor("yellow"));
graphics.draw("Engine: non (no nonsense) framework", 10, 34);
graphics.draw("Description: In this example we are testing music, input, tmx rendering, images and text displaying.", 10, 58);
graphics.draw(pressed, 10, 82, graphics.newColor("cyan"));
graphics.draw("FPS: " + game.getFPS(), 10, 104);
});

```
And, here is screenie demonstrating rendering for now:

![](http://eclipseorigins.com/community/filehost/bcb6cdb33cbcec317afae62db2d39a65.png)
Link to comment
Share on other sites

Thanks for kind words Sacra :) And it is never too late to switch from that libGDX mess ;)

New update, feedback please :)

I added proper loading screen when loading game data files at startup (only if you are using packed data and not extracted to directory). I had problems with this, I had to figure out proper threading. Also, here is new download (still no source code, sorry guys, but later I will post it to GitHub or PM me for source code. I will release this under MIT license, so easy to make games with this :P ).

Screenie demonstrating loading screen (can be changed ofc, but only from source)

![](http://eclipseorigins.com/community/filehost/646242c3e3d7d09a221cf683e55e4a4d.png)

And here is screenie demonstrating demo project in download (and some of features)

![](http://eclipseorigins.com/community/filehost/d2d4f9211a94b3c4c7131c67aed09193.png)
Link to comment
Share on other sites

Updated fw. Compiled it to Java 1.6, so this should fix issues on some PCs. Also, new large example map (try to resize window, looks great huh? :) )
New download link: [http://ge.tt/1POZj622/v/0](http://ge.tt/1POZj622/v/0).

In this update I partially finished input (but I will rework it for sure) and I started working on networking.

P.S: Please, anyone, downloading and trying to run this takes less than minute and I need to know if I compiled it good this time, becouse before it was working only on mine PC :/

![](http://eclipseorigins.com/community/filehost/409f941fb035432c5211df43f023e125.png)
Link to comment
Share on other sites

New update:

Replaced Java Nashorn scripting engine by Mozilla Rhino and wrote my own javax.script - like wrapper for it, so now NON should run also on Java 1.6 and greater. This was hard lol, but I think this does the job, so can anyone please try it and post here if it works?

**New download:** [http://ge.tt/7ixDWa22/v/0](http://ge.tt/7ixDWa22/v/0)

Also, I forgot to post example on how simple is to create client-server networking, so here it is:

```
// initialize networking with debug connection listener
non.network
.setHost("localhost")
.setPort(15600)
.setListener(non.extend(Listener, {
connected: function(conn) {
non.log("network, "client connected");
},
disconnected: function(conn, forced) {
non.log("network, "client disconnected");
},
receive: function(data, conn) {
non.log("network, "data received: " + data.read());
}
}));

// create and start client and server
(server = non.network.newServer()).listen();
(client = non.network.newClient()).connect();

```
Link to comment
Share on other sites

> Looks nice, I was looking at it, can't do anything by the looks of it, ut I was watching the fps and the sound; the sound was clear and great, the fps was all over the place, but high the whole time, and the screen flashed if I had chrome open and minimized in the background.

It is barebone now, you can edit it going to game folder and editing main.js file.

I am thinking about moving engine to CoffeeScript ([http://coffeescript.org/](http://coffeescript.org/)). What do you think guys? 

Current main.js:
```
non.init = function() {
// load tiled map and play music
map = non.tiled.newMap("map.tmx");
non.audio.play(non.audio.newMusic("music.ogg"));

// initialize networking with debug connection listener
non.network
.setHost("localhost")
.setPort(15600)
.setListener(non.extend(Listener, {
connected: function(conn) {
lastMsg = "client connected";
},
disconnected: function(conn, forced) {
lastMsg = "client disconnected";
},
receive: function(data, conn) {
lastMsg = "data received: " + data.read();
}
}));

// create and start client and server
(server = non.network.newServer()).listen();
(client = non.network.newClient()).connect();
lastMsg = "Waiting....";
};

non.update = function() {
// debug press of Spacebar through client-server connection
if (non.keyboard.isKeyJustPressed("Space")) {
var buffer = non.network.newBuffer();
buffer.write(1);
client.send(buffer);
}

// debug state of Spacebar through rendering to screen
if (non.keyboard.isKeyPressed("Space"))
pressed = "Key pressed: Spacebar (release Spacebar to test)";
else
pressed = "Key pressed: None (press Spacebar to test)";
};

non.draw = function() {
// drawing objects using method chaining
non.graphics
.draw(map)
.draw("Author: YourBestNightmare", 10, 10, non.graphics.newColor("yellow"))
.draw("Engine: non (no nonsense) framework", 10, 34)
.draw("Description: In this example we are testing music, input, tmx rendering, images and text displaying.", 10, 58)
.draw(pressed, 10, 82, non.graphics.newColor("cyan"))
.draw("FPS: " + non.getFPS(), 10, 104)
.draw(lastMsg, 10, 126, non.graphics.newColor("red"));
};

```main.js in CoffeeScript:
```
non.init = ->

# load tiled map and play music
map = non.tiled.newMap("map.tmx")
non.audio.play non.audio.newMusic("music.ogg")

# initialize networking with debug connection listener
non.network.setHost("localhost").setPort(15600).setListener non.extend(Listener,
connected: (conn) ->
lastMsg = "client connected"
return

disconnected: (conn, forced) ->
lastMsg = "client disconnected"
return

receive: (data, conn) ->
lastMsg = "data received: " + data.read()
return
)

# create and start client and server
(server = non.network.newServer()).listen()
(client = non.network.newClient()).connect()
lastMsg = "Waiting...."
return

non.update = ->

# debug press of Spacebar through client-server connection
if non.keyboard.isKeyJustPressed("Space")
buffer = non.network.newBuffer()
buffer.write 1
client.send buffer

# debug state of Spacebar through rendering to screen
if non.keyboard.isKeyPressed("Space")
pressed = "Key pressed: Spacebar (release Spacebar to test)"
else
pressed = "Key pressed: None (press Spacebar to test)"
return

non.draw = ->

# drawing objects using method chaining
non.graphics
.draw(map)
.draw("Author: YourBestNightmare", 10, 10, non.graphics.newColor("yellow"))
.draw("Engine: non (no nonsense) framework", 10, 34)
.draw("Description: In this example we are testing music, input, tmx rendering, images and text displaying.", 10, 58)
.draw(pressed, 10, 82, non.graphics.newColor("cyan"))
.draw("FPS: " + non.getFPS(), 10, 104).draw lastMsg, 10, 126, non.graphics.newColor("red")
return

```
Link to comment
Share on other sites

New update

* added support for CoffeeScript
* now script language is dynamically specified based on script file extension (.js for JavaScript, .coffee for CoffeeScript)
* game data is now also dynamically loaded (game data folder is specified by locating non.cfg file in it, works also for zip archives)

@Sacra Don´t worry, I added support for CoffeeScript, but also for JavaScript, developers can now use both :P

New download: [http://ge.tt/5CHrRo22/v/0](http://ge.tt/5CHrRo22/v/0)

I am planning to add also support for Ruby, Python and Clojure as scripting language, still deciding. What do you guys think?
Link to comment
Share on other sites

Thanks guys :) Scripting is working based on Mozilla Rhino.

I am deciding between implementing only TypeScript, JavaScript and CoffeeScript or finished implementing below languages. What do you think?

For now I implemented these languages: 

* ECMAScript/JavaScript -> [http://www.ecmascript.org/](http://www.ecmascript.org/)
* Move -> [http://movelang.org/](http://movelang.org/)
* Roy -> [http://roy.brianmckenna.org/](http://roy.brianmckenna.org/)
* CoffeeScript -> [http://coffeescript.org/](http://coffeescript.org/)

Implementing right now:

* Kaffeine -> [http://weepy.github.io/kaffeine/](http://weepy.github.io/kaffeine/)
* GorillaScript -> [http://ckknight.github.io/gorillascript/](http://ckknight.github.io/gorillascript/)

Going to implement after:

* TypeScript -> [http://www.typescriptlang.org/](http://www.typescriptlang.org/)

Maybe going to implement (these will require different interpreters as these cannot be compiled to JavaScript Rhino without node.js)

* Ruby -> [https://www.ruby-lang.org/](https://www.ruby-lang.org/)
* Lua -> [http://www.lua.org/](http://www.lua.org/)
* Python -> [https://www.python.org/](https://www.python.org/)

Why I am implementing that much languages? Becouse I can. Everyone should use what language are he/she comfortable in and using that much languages have 0 performance impact in NON becouse they are lazy-loaded (specific language compiler is loaded only when it is needed).
Link to comment
Share on other sites

Decided to not implement common languages such as Python, Ruby and Lua becouse I do not found fast enought compiler to JavaScript for them. So for now, supported languages are these:

* JavaScript
* TypeScript (by Microsoft)
* CoffeeScript
* Move
* Roy

Here is new download: [http://ge.tt/25AOA032/v/0](http://ge.tt/25AOA032/v/0)

I have confirmed that it is now also working on Java 1.6, so that is great :P

I uploaded source code to GitHub, so if anyone wanna look, send me PM and I will send you link.
Link to comment
Share on other sites

Thanks. I was working on python support but Jython do not supports java 6, so I will try to find older version of Jython and implement it. Also working on loading scripting frim multiple files, almost finished it because for now it only.supports one main file. Working on function non.load what will load and eval specified file.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share


×
×
  • Create New...