Wednesday, June 24, 2015

Hello World! -Haxe

Hello World! Haxe

Lets meet haxe, and follow the opening part of the tutorial from here.

if you haven't install haxe yet, follow the installation steps here.

Open terminal

Create file Hello.hx

$ nano Hello.hx

Type in the following source code :

class Hello {
      public static function main () {
           trace("Hello World!!");
      }
}

To compile, run the following command:

$ haxe -main Hello -neko Hello.n

This will create new file Hello.n
To run the file, type:

$ neko Hello.n

Hello.hx:3: Hello World!!


Basic Neko API

From http://api.haxe.org/neko/Lib.html#println :
"Print the specified value on the default output followed by a newline character."

Lets modified the Hello.hx

$ nano Hello.hx

class Hello {
      public static function main () {
           neko.Lib.println("Hello World!!");
      }
}

Save the file.
Compile it

$ haxe -main Hello -neko Hello.n

then run the file

$ neko Hello.n



Hey.. it's working!

HaxeFlixel on SolydK and Other Debian Based Distros

Lets install HaxeFlixel .

Lest install HaxeFlixel on SolydK64bit!

What is Haxe anyway?
Haxe is an open source toolkit based on a modern, high level, strictly typed programming language, a cross-compiler, a complete cross-platform standard library and ways to access each platform's native capabilities.

...and Flixel?
 Flixel is an open source game-making library that is completely free for personal or commercial use. Written entirely in Actionscript 3, and designed to be used with free development tools, Flixel is easy to learn, extend and customize.

...so, HaxeFlixel?
HaxeFlixel is Flixel port to use Haxe language. Create cross-platform games easier and free and all with one codebase. HaxeFlixel use OpenFL library.

...OpenFL?
OpenFL (Open Flash Library) is a fast, open-source implementation of the industry-standard Flash API. Unlike the Adobe implementation, OpenFL uses hardware rendering, compiles to native C++ for target platforms and reaches many more platforms than Adobe AIR. OpenFL is also 100% compatible with Flash Player, so you can still target Flash in the browser, or even AIR if you want. OpenFL uses the Haxe programming language.

 tl;dr

Downoad haxe from here.

Or you might want to visit the download page if the link is broken here.
Exstract it  


Install the script.
$ ./install-haxe.sh


Test your installation. Should look like this.
$ haxe

$ sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev g++ g++-multilib gcc-multilib


Install lime
$ haxelib install lime
$ haxelib run lime setup

do you want to install the "lime" command? [y]

Test the lime installation
$ lime

Install OpenFL
$ haxelib install openfl
$ haxelib run openfl setup

Test the openfl installation
$ openfl

Install Flixel
$ haxelib install flixel
$ haxelib install flixel-tools
$ haxelib run flixel-tools setup

Test the flixel installation
$ flixel



Now we will test with a new HaxeFlixel project.

Create new flixel template
$ flixel tpl -n "TestFlixel"

Browse into source directory
$ cd TestFlixel/source

Edit menustate.hx file
$ kate menustate.hx


Add code before super.create();

add(new FlxText(10, 10, 100, "Hello, World!"));
 

Save the file.


Go to the root directory project and run the command:

$ lime test linux -64

or

$ lime test neko


This is not an error. This is compiling the project.

note :
lime test neko
lime test linux -64
lime test windows
lime test mac 

Run this command from the root folder of your project, the default project.xml will be
used automatically. Using the test command will automatically launch the application created.


....and tadaa.


Hello, World!!!