I find myself doing something like this alot. Basically setting a condition to false to avoid the if block from running more than once.
If I do not turn it off, the mushroom will keep appearing.
The hacky code is isHit = false;
Given a update method that constantly get executed from the game loop in this pseudo code.
[code]
public class Mario{
public void collide()
{
Block.setHit(true)
}
}
[/code]
[code]
public class Block
{
public void setHit(boolean hit)
{
this.hit = hit;
}
public void update(long milliseconds)
{
if(isHit)
{
// hacky code
isHit = false;
Mushroom mushroom = new Mushroom(50,50);
Game.getInstance().add(mushroom);
}
}
}
So my question is: is hacky code allowed in the industry?
Do industry professionals or game developers use hacky code in their game code?
I always found hacky code to fix all the bugs in my game and let me progress faster in my game development process.