Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 07 Jun 2012
Offline Last Active Sep 14 2014 06:58 PM

Posts I've Made

In Topic: How to build a virtual machine

21 August 2014 - 06:56 PM



This is an older book, and has a terrible name.  It actually teaches how to build a scripting language compiler and virtual machine from the ground up.  It's written in C++, and not without some bugs in the code, but it is still a great book.  


I used this to make a scripting language, compiler, and virtual machine for my final project for my programming degree.  I was able to get math, variable, and recursive functions working, as well as embedding the language in C++ and adding C++ extensions to call C++ from the scripting language.


In Topic: Why Java games do not need installation

20 July 2014 - 09:14 PM

I never thought about this until now. The Java games I developed never need the installation treatment.

That only tells me your games aren't complex enough to require an installation procedure.
What happens if you want someone to play your game in Windows, and want your program installed in Program Files, with a Start-> programs menu, a desktop icon, and an uninstaller, wouldn't that need a dedicated installation procedure? Regardless of your game being made in Java, C or Haskell?

I developed a rpg in Java and it could be played fine without installation.

It seems to be a minor issue in terms of time if I wanted the user to go to the start menu to find my games when it could quickly be played after downloading the game to the desktop.

In Topic: Chosen polygon for bullets in fps game

20 June 2014 - 09:23 AM

Depends on the shape and how the projectiles is traveling in a path.

The projectiles in my 2d space shooter game do well using just basic rectangles.

But as you delve into weird projectiles going a more complicated trajectory, throwing a spear in the air will need a different approach.

In Topic: How to make a character fall off the block after it has been on it

04 June 2014 - 04:04 PM



Your question kind of answers your question.

Make separate states for "initiating the jump" and "jumping" (I like to call it "falling").

if(spacePressed && (state != ActionState.JUMPING))
state = ActionState.JUMP;
else if(state == ActionState.JUMP) // .... and then in the next frame
state = ActionState.JUMPING;


Good approach, but easily improved. There might be more situations. Jumping, falling, climbing, swimming, and more.


To make it more general:

if(spacePressed && CanJump())

Then add a short function that checks if they can jump. Perhaps they must be actually on the ground, must not be burdened or stunned, or otherwise incapable of jumping.


And to improve it yet again, why is jumping related to space?  What if they reassigned the keys, or are using an xbox controller or a mouse to control? Translate input from buttons to events as soon as you are able.  That gives this:

if(jumpPressed && CanJump()) {...}

which makes the intent even more clear to anyone maintaining the code later.


spacePressed is a boolean flag that is set to true when the space key is pressed

In Topic: How to make a character fall off the block after it has been on it

04 June 2014 - 02:27 PM

Warnexus, I assume, if your player steps off a platform and is falling, he won't be able to jump while falling right?  What I'm trying to get at is, you might need a generic solution which works whether you've just jumped or you're falling.


I'd suggest looking at trying to use a IsOnGround flag, unless you have a special can jump in mid air ability.

I managed to fix it. I decided to write a logic that tells the game that the character is off the block. So I can do something like this:


if(!onBlock && getY() + idleRightAnim.getHeight() < Screen.HEIGHT - 35)
         if(state != ActionState.JUMPING)
              state = ActionState.FALLING;