Friday, May 19, 2017

GUI Background, Evolution

 Different Stages of our Game GUI:
First Image
Second Image

Third Image
Final Image

Sunday, May 7, 2017

Added new Animations and 2 Characters

New Donkey Character, team Mexican
Running


Donkey Dying Animation

Donkey fighting Animation

Mexican Dying Animation

Mexican Fighting Animation
New Bull Character - Team Trump
Walking Animation



Dying Animation Trump

Fighting Animation Trump

Monday, April 24, 2017

Java | Memorry Consumtion | LinkedList Vs ArrayList

If memory matters, use ArrayList!
LinkedList might allocate fewer entries, but those entries are astronomically more expensive than they'd be for ArrayList -- enough that even the worst-case ArrayList is cheaper as far as memory is concerned.Louis Wasserman

Sunday, April 16, 2017

JavaFX | Having access of other Controllers from a specific Controller

There are some good ways to do this:
  1. Create a reference of a Controller
  2. private ControllerClass controller;
    
    /*...
    
    Parent root;
    FXMLLoader fxmlLoader = new FXMLLoader();
    fxmlLoader.setLocation(getClass().getResource("/path/ofYourFxml.fxml"));
    
    controller = fxmlloader.getController();
    //Now you can use a method like getter and setter to set or get any value of variable
    controller.yourMethodToCall()
    
    Stage stage = new Stage();
    stage.setScene(new Scene(root, 1200, 700));
    stage.show()
    
  3. For dirt and dirty solution: declare any variable you want to use in other class as static (Not recommended for a complex application(static problem))
  4. Use a shared data Model among Controllers
  5. Explaination follows...
    
    

Saturday, April 15, 2017

Java | Probably the most unused keyword in Java | The "volatile" keyword

In multithreaded application the behavior or the result of some processes might look very strange to a new programmer. (including me when i write this post)

The Problem

In multi cores computers, different Threads can be run on different cores. It make sense since you want to get the advantages of having multi cores. The problem comes when you are using primitive data types to control processes that handled by different threads. Primitive data types are stored in cache (L1) of a core in your CPU. These data are not shared between the cores. So the data that are using in one core is not equals with the data that used in other cores. This will lead to unexpected result of your program.

The Solution

Decorate your variable with a keyword "volatile" like this <code>private volatile int someInteger;</code>

JavaFx | How to populate a ListView with an arrayList

It is very simple: you have to pass your list (Collection.List) to an ObservableArrayList (FXCollection) like this. ObservableList anyList = FXCollections.observableArrayList(yourList)
transform an ArrayList into observableArrayList