The Melancholy of Right 31

Posted by (twitter: @asiekierka)
August 22nd, 2011 11:39 pm

(EDIT: You may want to play the game first. It’s a platformer game about throwing blocks on enemies. Timelapse: http://www.youtube.com/watch?v=TNpejFN19pQ http://www.youtube.com/watch?v=E5rtT8qZgyo )

Right! 31 hours of coding out (yes, I was fixing bugs after LD), and I could write up an explanation of how the game worked.

Main.java: It was supposed to run either the Game class or the Server class. That’s about it.

Common Files:

Block.java: Defines the block behaviour. Instead of playing with (co)sines, I decided to hardcode the directions, getting:

This is how real men write last-minute hacky code.

Yeah, it wasn’t as good as you think.

Enemy.java: Enemy behaviour. Falling code was a copy-paste from the player code in Game, and the rest is straightforward.

Map.java: Map code. Also, the most complicated part of the game.

First of all, “if(r>11) enemies.add(new Enemy(this,(i*16)+4,(rand.nextBoolean()&&(currpos<6)?(((currpos-1)*16)+8):((height-1)<<2)+8)));” Try to find out what this code does. DO IT

Second of all, it stored the player movement checking code. That wasn’t half bad for a simplified collision detection attempt, but it could be done easier (and faster (and better)).

Third of all, map painting code.

WHAT IS THIS CARP

This shows how hacked it was (I was adding wraparound near the end, mostly).

Fourth of all, I had a very easyway of checking whether a player was on. If they weren’t,

	px[i]=-1299293;
	py[i]=-9238223;

Straightforward, isn’t it?

Fifth and final,

THROB OFF

block throwing functionality.

MyRandom.java: A version of java.util.Random with a visible seed. Was experimenting.

CLIENT CODE:

Canvas.java: Basic canvas rendering code. Not half bad.

Game.java: My… what? It handled player movement, key handling, ticking map and network code, almost everything D:

First up,

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA

WAAAAAAAAAAAAAAAAAAAAAH IM SCARED

That leaves the key handling mostly alone, other than a trick that made moving faster when jumping, but… meh.

JUMPING AND FALLING WHAAAAAT

The Integrated Data Sentient Entity, after analyzing the subject, decided that a comment on this subject is not necessary.

Net.java: Fairly sane (but buggy) networking code.

SERVER:

Server.java: Uhh… fairly sane server connection acception code. Except this snippet:

LONG LINES

Client.java: Again, fairly sane networking code. Only pretty buggy.

How did I manage to LD without a PC?:

Battleship ASUS (EEE Pad Transformer) running a quickly hacked up Ubuntu. Which I had to fix 6 hours into the LD before I could finally start:

Battleship ASUS in action

Obligatory anime girl album cover on iPod connected to surround speakers included.

 

 

 

What did I learn?:

  • Race conditions will destroy your sanity. ONCE AND FOR ALL
  • Sometimes, generic code is better than making a solution yourself. Not always the case.
  • I should try to plan out work more than “Singleplayer: Day 1, Multiplayer: Day 2” next time.
  • NEVER WORK ON GNOME AGAIN
  • BUGTEST EVERY SECOND

Thanks for reading. If you tl;dr, :<

 

 

 

 

 

 

 

 


Leave a Reply

You must be logged in to post a comment.

[cache: storing page]