Page 2 of 7 FirstFirst 1234 ... LastLast
Results 11 to 20 of 63

Thread: 2nd PGD Challenge - "Platformation"

  1. #11
    Hey all,
    any chance of trying the same simple demo (drawing blue box, Escape key exits...) on your computers (windows only ATM)?
    Debug.zip

    I think that all you need is Java.exe installed and somewhere on your path...

    I need to know if other people can run my Oxygene programs before I progress any further
    Just unzip it (makes a folder), and run the platformation.jar file; either double click if associated with Java, or open with and select Java.

    Thanks guys!
    cheers,
    Paul

  2. #12
    Ok, I have done some more of the game and have hit a runtime error that I just can't figure out:
    Code:
    Loading module
    Please note: some java.lang.ClassNotFoundExceptions can be expected during project startup.
    An exception of type: java.lang.ClassNotFoundException occurred
    An exception of type: java.lang.ClassNotFoundException occurred
    An exception of type: java.lang.ClassNotFoundException occurred
    An exception of type: java.lang.ClassNotFoundException occurred
    An exception of type: java.lang.ClassNotFoundException occurred
    An exception of type: java.lang.ClassNotFoundException occurred
    An exception of type: java.lang.ClassNotFoundException occurred
    An exception of type: java.lang.ClassNotFoundException occurred
    An uncaught exception of type: java.lang.VerifyError occurred
    Message: 'java.lang.VerifyError: (class: paulfnicholls/game/platformation/GameLevel, method: SetBounds signature: (IIII)V) Illegal creation of multi-dimensional array'
    
    At: 
      paulfnicholls.game.platformation.GameApplication.InitGame
      paulfnicholls.game.platformation.GameApplication.Run
      paulfnicholls.game.platformation.GameApplication.main
    The program 'C:\Program Files (x86)\Java\jre6\bin\java.exe' has exited with code -1 (0xffffffff).

  3. #13
    Main file in project:
    Code:
    namespace paulfnicholls.game.platformation;
    
    interface
    uses
      org.lwjgl,
      org.lwjgl.input,
      org.lwjgl.opengl,
      org.lwjgl.util.glu;
    
    type
      //
      // GameApplication class
      //
      GameApplication = public class
      private
        const cScreenWidth  = 800;
        const cScreenHeight = 600;
        const cTileWidth    = 32;
        const cTileHeight   = 32;
        var
        FScreenWidth  : Integer;
        FScreenHeight : Integer;
        FLevel        : GameLevel;
    
        method InitGame;
        method CleanupGame;
        method InitGL;
    
        method RenderTile_Ground(aTile: GameTile; aX,aY: Single);
        method RenderFrame;
      public
        method Run();
        class method main(argv: array of String);
      end;
    
    implementation
    
      //
      // GameApplication class
      //
    method GameApplication.InitGame;
    begin
      FScreenWidth  := cScreenWidth;
      FScreenHeight := cScreenHeight;
    
      FLevel := new GameLevel;
      FLevel.SetBounds(10,10,cTileWidth,cTileHeight);
    
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Earth ,@RenderTile_Ground);
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Air   ,@RenderTile_Ground);
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Fire  ,@RenderTile_Ground);
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Water ,@RenderTile_Ground);
    end;
    
    method GameApplication.CleanupGame;
    begin
      FLevel := nil;
    end;
    
    method GameApplication.InitGL;
    begin
      GL11.glViewport(0, 0, FScreenWidth, FScreenHeight);
    
      GL11.glMatrixMode(GL11.GL_PROJECTION);
      GL11.glLoadIdentity();
      GLU.gluOrtho2D(0, FScreenWidth, FScreenHeight, 0);
      GL11.glMatrixMode(GL11.GL_MODELVIEW);
    
      GL11.glEnable(GL11.GL_DEPTH_TEST);
    
      GL11.glClearColor (0, 0, 0, 0);
    end;
    
    method GameApplication.RenderTile_Ground(aTile: GameTile; aX,aY: Single);
    var
      x1,y1,x2,y2 : Single;
      w,h         : Single;
    begin
      GL11.glColor3f(0.5,0.5,1.0);
        
      w  := cTileWidth;
      h  := cTileHeight;
      x1 := aX;
      y1 := aY;
      x2 := aX + w;
      y2 := aY + h;
    
      // draw tile quad
      GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2f(x1,y1);
        GL11.glVertex2f(x2,y1);
        GL11.glVertex2f(x2,y2);
        GL11.glVertex2f(x1,y2);
      GL11.glEnd();
    
      GL11.glColor3f(1,0,0);
      GL11.glBegin(GL11.GL_LINE_LOOP);
        GL11.glVertex2f(x1,y1);
        GL11.glVertex2f(x2,y1);
        GL11.glVertex2f(x2,y2);
        GL11.glVertex2f(x1,y2);
      GL11.glEnd();
    end;
    
    method GameApplication.RenderFrame;
    begin
    //  FLevel.Render;
    {  // set the color of the quad (R,G,B,A)
      GL11.glColor3f(0.5,0.5,1.0);
                
      // draw quad
      GL11.glBegin(GL11.GL_QUADS);
      GL11.glVertex2f(100,100);
      GL11.glVertex2f(100+200,100);
      GL11.glVertex2f(100+200,100+200);
      GL11.glVertex2f(100,100+200);
      GL11.glEnd();}
    end;
    
    method GameApplication.Run();
    begin
      InitGame;
      try
        try
          Display.setDisplayMode(new DisplayMode(FScreenWidth, FScreenHeight));
          Display.create();
        except
          on e: LWJGLException do
          begin
            e.printStackTrace();
            System.exit(0)
          end; 
        end;
    
        //  init OpenGL here
        InitGL;
    
        Display.Title := 'Platformation';
    
        while not Display.isCloseRequested() do 
        begin
          GL11.glClear(GL11.GL_COLOR_BUFFER_BIT or GL11.GL_DEPTH_BUFFER_BIT);
          GL11.glLoadIdentity;
    
          RenderFrame;
    
          Display.update();
          Display.sync(60);
    
          if Keyboard.isKeyDown(Keyboard.KEY_ESCAPE) then Break;
        end;
      finally
        CleanupGame;
      end;
    
      Display.destroy()
    end;
    
    class method GameApplication.main(argv: array of String);
    begin
      var App: GameApplication := new GameApplication();
      App.Run()
    end;
    
    end.
    classes 'unit':
    Code:
    namespace paulfnicholls.game.platformation;
    
    interface
    
    type
      //
      // GameTile class
      //
      GameTile = public class
      public
        const cTileType_Space  = 0;
        const cTileType_Ground = 1;
        const cNumTileTypes    = 2;
    
        const cTileTheme_Earth = 0;
        const cTileTheme_Air   = 1;
        const cTileTheme_Fire  = 2;
        const cTileTheme_Water = 3;
        const cNumTileThemes   = 4;
    
        var
        Id      : Integer;
        Theme   : Integer;
        IsSolid : Boolean;
    
        constructor(aId,aTheme: Integer; aIsSolid: Boolean);
      end;
    
      //
      // GameLevel class
      //
      RenderTileRoutine = delegate(aTile: GameTile; aX,aY: Single);
    
      LevelRow   = array of GameTile;
      LevelLayer = array of LevelRow;
    
      GameLevel = public class
      private
        FLevelWidth  : Integer;
        FLevelHeight : Integer;
        FTileWidth   : Integer;
        FTileHeight  : Integer;
        FLevel       : LevelLayer;
        FRenderTile  : array of RenderTileRoutine;
      public
        constructor;
    
        method SetBounds(aLevelWidth,aLevelHeight,aTileWidth,aTileHeight: Integer);
        method RegisterRenderTileRoutine(aTileType: Integer; aRenderTileRoutine: RenderTileRoutine);
        method Render;
    
        method GetTileX(aX: Single): Integer;
        method GetTileY(aY: Single): Integer;
      end;
    
    implementation
    
      //
      // GameTile class
      //
    constructor GameTile(aId,aTheme: Integer; aIsSolid: Boolean);
    begin
      inherited Constructor;
    
      Id      := aId;
      Theme   := aTheme;
      IsSolid := aIsSolid;
    end;
    
      //
      // GameLevel class
      //
    constructor GameLevel;
    var
      i: Integer;
    begin
      inherited Constructor;
    
      SetBounds(10,10,32,32);
    
      FRenderTile := new RenderTileRoutine[GameTile.cNumTileTypes]; 
      for i := 0 to length(FRenderTile) - 1 do FRenderTile[i] := nil;
    end;
    
    method GameLevel.SetBounds(aLevelWidth,aLevelHeight,aTileWidth,aTileHeight: Integer); 
    var
      x,y: Integer;
    begin
      FLevelWidth  := aLevelWidth;
      FLevelHeight := aLevelHeight;
      FTileWidth   := aTileWidth;
      FTileHeight  := aTileHeight;
    
      FLevel := new LevelLayer(FLevelHeight);
      for y := 0 to FLevelHeight - 1 do
      begin
        FLevel[y] := new LevelRow(FLevelWidth);
    
        for x := 0 to FLevelWidth - 1 do
        begin
          if (x = 0) or (x = FLevelWidth - 1) or (y = 0) or (y = FLevelHeight - 1) then
            FLevel[y,x] := new GameTile(GameTile.cTileType_Ground,GameTile.cTileTheme_Earth,True)
          else
            FLevel[y,x] := new GameTile(GameTile.cTileType_Space,GameTile.cTileTheme_Earth,False);
        end;
      end;
    end;
    
    method GameLevel.RegisterRenderTileRoutine(aTileType: Integer; aRenderTileRoutine: RenderTileRoutine);
    begin
      FRenderTile[aTileType] := aRenderTileRoutine;
    end;
    
    method GameLevel.Render;
    var
      x,y : Integer;
      t   : GameTile;
    begin
      for y := 0 to FLevelHeight - 1 do
        for x := 0 to FLevelWidth - 1 do
        begin
          t := FLevel[y,x];
    
          if (t.Id <> GameTile.cTileType_Space) and assigned(FRenderTile[t.Id]) then
          begin
            FRenderTile[t.Id](t,x * FTileWidth,y * FTileHeight);
          end;
        end;
    end;
    
    method GameLevel.GetTileX(aX: Single): Integer;
    begin
      Result := Integer(Math.floor(aX / FTileWidth));
    end;
    
    method GameLevel.GetTileY(aY: Single): Integer;
    begin
      Result := Integer(Math.floor(aY / FTileHeight));
    end;
    
    end.
    I can't see what the issue is with the 'multi dimensional array complaint' and GameLevel.SetBounds()...

    Any idea Oxygene experts?

  4. #14
    When it crashes and I hit break, it stops at this line:

    Code:
    method GameApplication.InitGame;
    begin
      FScreenWidth  := cScreenWidth;
      FScreenHeight := cScreenHeight;
    
      FLevel := new GameLevel; **** <-------------------  stops here ---------  *******
      FLevel.SetBounds(10,10,cTileWidth,cTileHeight);
    
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Earth ,@RenderTile_Ground);
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Air   ,@RenderTile_Ground);
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Fire  ,@RenderTile_Ground);
      FLevel.RegisterRenderTileRoutine(GameTile.cTileTheme_Water ,@RenderTile_Ground);
    end;
    HELP!!!
    Last edited by paul_nicholls; 16-04-2012 at 03:24 AM.

  5. #15
    You have an array of array, maybe that isn't supported?

    Code:
      LevelRow   = array of GameTile;
      LevelLayer = array of LevelRow;
    you could try changing it to a fixed-size array, or a single-dimensional array, and then access it by LevelLayer[y*nbColumns+x] ?

  6. #16
    Quote Originally Posted by Eric View Post
    You have an array of array, maybe that isn't supported?

    Code:
      LevelRow   = array of GameTile;
      LevelLayer = array of LevelRow;
    you could try changing it to a fixed-size array, or a single-dimensional array, and then access it by LevelLayer[y*nbColumns+x] ?
    LOL! By Jove...you are right, that IS a multi dimensional array...I will change it to 1d and see if it works then

    EDIT: That worked, thanks Eric!!

  7. #17
    Hey all,
    any chance of trying the same simple demo (drawing blue box, Escape key exits...) on your computers (windows only ATM)?
    Debug.zip

    PS
    . has anyone tried the attachement from my other post to see if they can run Oxygene for Java created programs?

  8. #18
    I haven't done it jet becouse I'm at work now. I'll do when I get home.

  9. #19
    No problem...when ever you can would be most helpful

  10. #20
    I just tried your example and it runs without any problem. I do have latest java client instaled on my computer thou. Cant know how it might behave with older clients.

Page 2 of 7 FirstFirst 1234 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •