Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (726)
Games in Android Showcase (216)
games submitted by our members
Games in WIP (796)
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 / Game Mechanics / Re: Faster tile drawing. on: 2013-05-13 15:26:07
Well, i have a 3 dimensional array (layers*width*height) witch contains 4 layers of tiles (each tiles holds 4 variables : an array of Strings "propeties", a boolean "animated", int speed [of the animation], and a array of tileSprite ID's [i.e. 4,5,6] ). The render funtion loops throught the array and draws the tileSprites based on the tile's current id (the tiles dont have any kind of time counter, the id is chosen by some simple algorithm). The tiles have also a function : returnWithNextID() witch returns the tile with it's next id, if it has any (useful if you have for example 2 states of a door tile, opened and closed).

Here is the render function:

public void render(int x,int y,int startTileX,int startTileY,int width,int height,int layer,Graphics g){
      int twidth = getTileWidth();
      int theight = getTileHeight();
      long time = System.currentTimeMillis();
      Tile tile;
      int frame;
      //Reminder: to use this function call ImageBag.tileSheet.startUse(); before calling it and ImageBag.tileSheet.endUse(); after calling it.
      for(int tx = startTileX; tx < startTileX+width && x < layers[0].length;tx++){
         for(int ty = startTileY; ty < startTileY+height && y < layers[0][0].length;ty++){
            tile = getTile(tx,ty,layer);
               frame = (int)(  (time/(100*tile.speed))%tile.getAllTheIds().length);
               ImageBag.tiles[tile.getAllTheIds()[frame]].drawEmbedded(x+((tx-startTileX)*twidth), y+((ty-startTileY)*theight),Tile.WIDTH,Tile.HEIGHT);
               ImageBag.tiles[tile.getId()].drawEmbedded(x+((tx-startTileX)*twidth), y+((ty-startTileY)*theight),Tile.WIDTH,Tile.HEIGHT);


PS: In the Map.class there is also a 2d array of booleans for collision detection (solid|passable).
2  Game Development / Game Mechanics / Re: Faster tile drawing. on: 2013-05-12 14:19:10
That's on big ass post xd Well i think i get what you mean, but there is one small problem, some tiles are animated, some are not.And as for lighting, yes it's possible because all i do is draw a map of (smaller thus more) colored tiles (mostly black) with different opacities. I started reading on the smapling stuff but i still dont know how to do it properly. Could you please show me how to do it explain it to me Cheesy ? It would help me A LOT.

- Alex

3  Game Development / Game Mechanics / Re: Faster tile drawing. on: 2013-05-12 09:36:23
Whoa, thanks for the replies! Unfortunately i didn't gain any fps by changing things to what davedes said (changed renderer to Vertex Array Renderer, started using spritesheets) but that doesn't bother me now because of the article davedes posted xd (thanks!). Oh and Jimmit, the game is not on Android Cheesy


PS: After looking at LibGDX, i think i will switch to it in the next project.
4  Game Development / Game Mechanics / Faster tile drawing. on: 2013-05-11 22:15:49
Hello Cheesy Im programming a dungeon crawler in Slick2D and i have stumbled upon a big wall X.X Yes, it's the FPS.
I am currently drawing (the visible part of) 4 tile layers + 1 lighting layer (there are also other things like gui & entity systems). I have a stable 90-120 FPS but considering the amount of logic that still needs to be added (AI,NPC'S,pets,combat system,buff system,spell system, particle effects etc. etc.) i need something around 500.
Now i have seen THIS AWESOME article Cheesy but unfortunately my graphics card doesn't support OpenGL 3.0 :C (everything is working besides the texture loading - OpenGL 3.0 ). Now my question is Is there any way to achieve the same performance-boost with OpenGL 2.0? If there is, could you please explain? Im kinda newbie to OpenGL.

5  Game Development / Game Mechanics / Re: Entity knockback on: 2013-04-21 09:11:53
Whoa i didn't expect code! Thanks  Grin ! I think i will add knockbackTimer an knockbackTo to the Velocity component and do the logic in some system. Thanks again  Grin !

PS : r is radians , right? Or degrees?
6  Game Development / Game Mechanics / Entity knockback on: 2013-04-20 17:54:34
Hi, can someone please tell me how to add knock-back? My entities have x,y,velocityX and velocityY variables, and i have just no idea how to add it. I can like add 5 to velocityX for example, but how do i decrease it? And if the entity has bumped into something and it's velocity is set to 0, how do i make it so that it stops decreasing?Maybe add separate fields, but that destroys the purpose of one velocity vector, doesn't it? Please help me :c

PS: Using Artemis.
Pages: [1]
Archive (282 views)
2017-04-27 17:45:51

buddyBro (472 views)
2017-04-05 03:38:00

CopyableCougar4 (921 views)
2017-03-24 15:39:42

theagentd (933 views)
2017-03-24 15:32:08

Rule (946 views)
2017-03-19 12:43:22

Rule (913 views)
2017-03-19 12:42:17

Rule (916 views)
2017-03-19 12:36:21

theagentd (962 views)
2017-03-16 05:07:07

theagentd (890 views)
2017-03-15 22:37:06

theagentd (686 views)
2017-03-15 22:32:18
List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05

SF/X Libraries
by SkyAphid
2017-03-02 06:38:56

SF/X Libraries
by SkyAphid
2017-03-02 06:38:32

SF/X Libraries
by SkyAphid
2017-03-02 06:38:05

SF/X Libraries
by SkyAphid
2017-03-02 06:37:51 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
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!