So me and a friend recently began (trying) to develop some basic 2d games, we feel like we’ve been doing ok considering the short time we’ve been doing this for. Now we ask ourselves, how do we continue to learn and improve? What would you have done next if you were in our inexperienced shoes? Any tips or ideas are greatly appreciated!
What we’ve made so far is(And what problems we have with them, please do help!):
A puzzle game inspired by a memory we made for school - the game’s basically a grid of (objects extending) JButtons and you move your character around trying to solve different puzzles to advance to the next level. Here’s some screen shots of the game:
There’s also a basic map editor which saves the maps into .txt files which in turn can be read as custom maps in the game. (And to develop the actual maps of the ‘campaign’)
I’ve also made a chess game using the same technique with them JButtons, you press a piece you want to move, if its your turn, and it will show you all the available moves for that piece - nothing worth showing.
We’ve made a basic Super Mario kind of platform game - beat the map, jump on enemies to kill them. Some enemies patrol until they can not continue any further and then turn around and go the other way, some enemies jump on the spot until they’ve been killed. We came across a big problem here: When we move outside the main picture - the frame you see when you first start the game, and we want the ‘camera’ to follow: We did this the following way:
If you are moving to the right, instead of moving the characters X position 1 pixel to the right, we move every other object one pixel to the left. This same goes for if we move left, up or down - works great BUT if we move and an enemy moves on the same time they can sometimes fall through the ground or move through a wall because:
We start to move all the objects one by one. We move a wall one step down, then the gravity pulls the enemy down to the wall, then we move the enemy one step down - and blam he’s past the floor and floating towards eternity! How can we solve this? Any ideas? I was thinking of using JLayeredPane but I cant get it to work and I’ve never used it before so I don’t even know if it would of worked!
We then started to think about some network programming, had some trouble until we found ‘Kryonet’ (god what a relief - it’s awesome!), and made a chat server and client:
And started making a small two player online game where you’re supposed to be a ninja (atm you’re just a green (or red, depending on damage taken) square!) throwing knifes on your opponent until hes dead and you’ve won the game! You can jump on the knifes - but if their edge hits you you will take damage, and throw slow knives if you want to (to make it easier to jump on them to avoid your opponents knives!).
Now when we started doing the later kind of games we’ve run into a bit of trouble. We have all of our knives, characters and walls in a ArrayList go, but when we try to iterate through this array to check collisions we got all sorts of different weird errors - we managed to remove most of them but we’re still stuck with a “No such element exception” in a for each loop:
temp = (ArrayList) go.clone();
for (GameObject gs : temp) {
if (temp.contains(gs) && !(gs == null)) {
if (gs instanceof Wall || gs instanceof Knife || gs instanceof Character) {
if (gs.getY() == ypos) {
if (gs.getX() < xrightpos && gs.getX() + gs.getWidth() > xleftpos) {
standingOnWall = true;
}
}
}
}
}
The game runs smooth in most cases, we’ve been testing it online versus each others and we can complete most games without any errors - even if we in some games have up to (probably) 100 knives(and threads) active on the same time! But sometimes we get the error I mentioned above and we have absolutely no idea on how to solve this. If you’ve got any ideas on this then please help me out!