Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (408)
games submitted by our members
Games in WIP (293)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1]
1  Game Development / Performance Tuning / Re: Better way of doing this? on: 2009-03-07 19:03:06
You won't get much more efficient without actually compiling GML to bytecode, but I must say that I find the type system absolutely horrible. "Hello, World" + 1 = 1?!
Actually "Hello, World" + 1 = "Hello, World1"
As it uses the string add function.

Yeah I suppose it is horrible but I can't think of a better way of doing things Undecided.
2  Game Development / Performance Tuning / Better way of doing this? on: 2009-03-07 18:00:29
This is quite a strange project but I will try to explain it. It takes code from an application called game maker (www.yoyogames.com) and converts that code to java.
In the game maker language (gml) you don't need to declare variables, you just use them, and you can use a variable that is not defined yet from another 'object'. Also variables can be either double or string and it can change from one to the other.
The current system works but since I am just a hobby programmer I don't have very much experience so there could be a faster way to do it. Speed is important because its the backend of all the games. Its already faster than gm but i still would like to know if it can be any faster.

here is an example how the current system will convert gml:
gml:
Quote
s=s+1
java:
Quote
{self.setVariable("s",self.getVariable("s") .add((Game.getValueOf(1))));}

It uses a hashtable to store all the variable names with their values:
Quote
public void setVariable(java.lang.String name, Variable value) {
        variables.put(name, value);
    }

/*
     * Gets the value of the variable with string name.
     *
     */
    public Variable getVariable(java.lang.String name) {
        Variable o = (Variable) variables.get(name.toString());
        if (o == null) {
            o=new Integer(0);
            variables.put(name.toString(),o );
            return o;
        }
        return o;
    }

Code for Game.getValueOf():
Quote
public static Variable getValueOf(int i){
        NUMBER_VARIABLE=integers.get(i);
        if (NUMBER_VARIABLE !=null){
        return NUMBER_VARIABLE;
        }
        else {
            NUMBER_VARIABLE=new Integer(i);
        integers.put(i, NUMBER_VARIABLE);
        return NUMBER_VARIABLE;
        }

    }
It also uses a hashtable to store all numbers that will be used, to save memory rather than doing new Integer() every time.

Heres some more source files if you need to see them:
http://gjava.svn.sourceforge.net/viewvc/gjava/Dolphin/src/org/dolphin/game/api/types/

Thats basically the system, it uses hashtables and Variable objects to get and set variables. is their a more efficient way of doing this.

I appreciate any help Smiley
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Try the Free Demo of Revenge of the Titans

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
cubemaster21 (119 views)
2013-05-17 21:29:12

alaslipknot (126 views)
2013-05-16 21:24:48

gouessej (157 views)
2013-05-16 00:53:38

gouessej (147 views)
2013-05-16 00:17:58

theagentd (162 views)
2013-05-15 15:01:13

theagentd (147 views)
2013-05-15 15:00:54

StreetDoggy (191 views)
2013-05-14 15:56:26

kutucuk (215 views)
2013-05-12 17:10:36

kutucuk (214 views)
2013-05-12 15:36:09

UnluckyDevil (217 views)
2013-05-12 05:09:57
Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38

Java Data structures
by Roquen
2013-03-29 13:21:12

Topic Request
by kutucuk
2013-03-22 21:42:01
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!
Page created in 0.085 seconds with 21 queries.