Summer project

Hello everyone! As you know, the summer has come and this is the last week of school (wop wop). So now i have a lot of free time to skate (i’m a rollerblader) and to start making a game. Yesterday i started developing my first serious project (i hope so) of a 2D game wrote in Java and using Slick2D.

This is a blog where i will post every update i do: http://sgamed.blogspot.ro/

Also, if you want to see what i am doing on skates, check my youtube channel : http://www.youtube.com/user/eNoorProductions
Check one of my videos :

uj0Gt3Oq428

I plan on tracking your IP, finding you, and stealing your rollerskating talent; if that’s okay. :stuck_out_tongue:

Anyway, good luck on your project. I suggest using OpenGL or Slick2d, as Java2D isn’t the best for game making, but if it’s 8-bit-simple, you shouldn’t have any problems.

Good luck, mane.

Edit:
Read that blog, you’re using Slick2D. Good choice lol

Haha, lol. Thanks. Firstly i wanted to try using LWJGL but OpenGL owned me in 2 days. :))

Impressive progress for such a short time. But if you’re going to blog about it I would expect some more details, such as how you do certain things. If you don’t spill the beans people won’t have much of a reason to keep an eye on your stuff :slight_smile:

Thanks. As i said, this is my first “big” project, so it’s the first time i do blog it. Thank you for advice i will do like you said. :slight_smile:

I hope i can ask one question here: In Slick2D, i should still place every Tile from a TiledMap in an array to lately render only what is in screen or is this process automatically done by Slick? Also, can someone point me to best mode to do the “depth” ?

Yeaaah! I have found the easiest way to render only the visible tile. It is so simple, i didn’t even think at this. :slight_smile:

This was my render code:

public void render(GameContainer container, Graphics g)  {
        g.translate(xOffset, yOffset);
        g.setAntiAlias(false);
        
        //Floor
        currentLevel.render(0, 0, currentLevel.getLayerIndex("floor"));
        currentLevel.render(0, 0, currentLevel.getLayerIndex("floordec"));

        for(int y = 0; y < currentLevel.getHeight(); y++) {

                //Rendering entities
                for(int i = 0; i < lLoader.getEntities().size(); i++) {
                        Entity currEntity = (Entity) lLoader.getEntities().get(i);
                        if(currEntity.getY() + currEntity.getHeight() >= y * 32 && currEntity.getY() + currEntity.getHeight() < (y + 1) * 32)
                                currEntity.render(g);
                }

                //Rendering tiles
                currentLevel.render(0, y * 32, 0, y, currentLevel.getWidth(), 1, currentLevel.getLayerIndex("walls"), false);
                currentLevel.render(0, y * 32, 0, y, currentLevel.getWidth(), 1, currentLevel.getLayerIndex("lowobjects"), false); 
                currentLevel.render(0, (y - 1) * 32, 0, y - 1, currentLevel.getWidth(), 2, currentLevel.getLayerIndex("highobjects"), false);
        }
}

And now it is like :

public void render(GameContainer container, Graphics g)  {
		g.translate(xOffset, yOffset);
		g.setAntiAlias(true);
		
		//RENDERING		
		//Floor
		
		currentLevel.render((-xOffset / 32) * 32, (-yOffset / 32) * 32, -xOffset / 32, -yOffset / 32, WIDTH / 32 + 1, HEIGHT / 32 + 2, currentLevel.getLayerIndex("floor"), false);
		currentLevel.render((-xOffset / 32) * 32, (-yOffset / 32) * 32, -xOffset / 32, -yOffset / 32, WIDTH / 32 + 1, HEIGHT / 32 + 2, currentLevel.getLayerIndex("floordec"), false);
		
		for(int y = -yOffset / 32; y < -yOffset / 32 + HEIGHT / 32 + 1; y++) {
			
			//Rendering entities
			for(int i = 0; i < lLoader.getEntities().size(); i++) {
				Entity currEntity = (Entity) lLoader.getEntities().get(i);
				if(currEntity.getY() + currEntity.getHeight() >= y * 32 && currEntity.getY() + currEntity.getHeight() < (y + 1) * 32)
					currEntity.render(g);
			}
			
			//Rendering tiles
			currentLevel.render((-xOffset / 32) * 32, y * 32, -xOffset / 32, y, WIDTH / 32 + 1, 1, currentLevel.getLayerIndex("walls"), false);
			currentLevel.render((-xOffset / 32) * 32, y * 32, -xOffset / 32, y, WIDTH / 32 + 1, 1, currentLevel.getLayerIndex("lowobjects"), false); 
			currentLevel.render((-xOffset / 32) * 32, (y - 1) * 32, -xOffset / 32, y - 1, WIDTH / 32 + 1, 2, currentLevel.getLayerIndex("highobjects"), false);
		}
}

I only needed to do some math. :stuck_out_tongue:

Blog is updating, so be sure you checked it. :smiley:

I’m making progress with the game. Check out here: http://sgamed.blogspot.ro/

for(int i = 0; i < lLoader.getEntities().size(); i++) {
            Entity currEntity = (Entity) lLoader.getEntities().get(i);

To me this looks a bit strange. lLoader.getEntities() should return a list/set of Entity right? that means you shouldn’t have to cast.
You can also loop through all the entities like this, which should be a bit faster:

for (Entity currEntity: lLoader.getEntities()){
...
}

Other than that, good work. :slight_smile:

You are somehow right, then i was using Bags (custom collections) that don’t have an iterator, but now i changed back to ArrayList to make the code simple. In my case, there is no speed change between Bag and ArrayList because I use Slick2D, but first time when i tried to make a game, using Java2D, there was a big difference between speeds.

Thanks!

@roland
The second loop creates new Itelator each time as I recall.

Alright guys, here comes some new updates and future plans. :smiley:
http://sgamed.blogspot.ro