Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (107)
games submitted by our members
Games in WIP (534)
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 17: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:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
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);
            if(tile.animated){
               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);
            }else{
               ImageBag.tiles[tile.getId()].drawEmbedded(x+((tx-startTileX)*twidth), y+((ty-startTileY)*theight),Tile.WIDTH,Tile.HEIGHT);
            }
         }
      }
   }



-Alex


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 16: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 11: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

-Alex


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-12 00: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 http://www.java-gaming.org/topics/rendering-tiles-fast-isometric-too/25292/view.html 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.

-Alex
5  Game Development / Game Mechanics / Re: Entity knockback on: 2013-04-21 11: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 19: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]
 

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

The first screenshot will be displayed as a thumbnail.

pw (35 views)
2014-07-24 01:59:36

Riven (33 views)
2014-07-23 21:16:32

Riven (21 views)
2014-07-23 21:07:15

Riven (24 views)
2014-07-23 20:56:16

ctomni231 (55 views)
2014-07-18 06:55:21

Zero Volt (47 views)
2014-07-17 23:47:54

danieldean (38 views)
2014-07-17 23:41:23

MustardPeter (43 views)
2014-07-16 23:30:00

Cero (59 views)
2014-07-16 00:42:17

Riven (56 views)
2014-07-14 18:02:53
HotSpot Options
by dleskov
2014-07-08 03:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 00:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 11:13:37

HotSpot Options
by Roquen
2014-05-15 09:59:54

HotSpot Options
by Roquen
2014-05-06 15:03:10

Escape Analysis
by Roquen
2014-04-29 22:16:43

Experimental Toys
by Roquen
2014-04-28 13:24:22
java-gaming.org 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‑gaming.org
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!