Whack a Mole
by Quest Johnny · in Torque Game Builder · 08/05/2006 (7:12 pm) · 4 replies
I thought I'd create a thread so we could put all the issues into it.
General: The previous tutorials really held your hand. Whack a mole kinda throws things at you and says "god bless" - written by the same guy? Anyway, here's a couple of points for those who come after me:
The code as given does not update MISSED, or it does and I just completely did something wrong. Regadless, the fix is this:
function mole::onAnimationEnd(%this)
{
//echo("animated ended:" @ %this.getAnimationName() );
if( %this.getAnimationName() $= ("animMoleWhacked" @ %this.moleColor) )
{
// free the respawn point for other moles
%this.respawnPoint.isOccupied = "";
// decrement the occupied counter
%this.sceneGraph.spawnPointsOccupied -= 1;// after deleting the old mole schedule a respawn
// >%this.sceneGraph< is the level
echo("animation ended:" SPC %this.getAnimationName() );
echo("on mole:" @ %this.moleColor);
// update score
//if( %this.getAnimationName() $= ("animMoleWhacked" @ %this.moleColor) )
%this.scenegraph.incWhackedCount();
%this.sceneGraph.schedule( 1500, "spawnMole");
%this.safeDelete();
} else
if( %this.getAnimationName() $= ("animMoleDiveIn" @ %this.moleColor) ) {
%this.scenegraph.incMissedCount();
}//if
}//F
Instead of what is given, then it works.
Also, in the example, Scenegraph should be scenegraph, but if you take my code you'll be fine.
It took me a long while to figure out why the animations had to be named by color, if they were already on the mole, but I did figure it out, so I pass that along:
All the moles are based off a SINGLE sprite, which contains green, red and lilac frames for the moles and animations. Therefore, in order to trigger the "green dive in" you have to always tell it it is a 'green' mole. I would have recommended making 3 sprites for red, green, and purple just for the sake of the tutorial and clarity.
General: The previous tutorials really held your hand. Whack a mole kinda throws things at you and says "god bless" - written by the same guy? Anyway, here's a couple of points for those who come after me:
The code as given does not update MISSED, or it does and I just completely did something wrong. Regadless, the fix is this:
function mole::onAnimationEnd(%this)
{
//echo("animated ended:" @ %this.getAnimationName() );
if( %this.getAnimationName() $= ("animMoleWhacked" @ %this.moleColor) )
{
// free the respawn point for other moles
%this.respawnPoint.isOccupied = "";
// decrement the occupied counter
%this.sceneGraph.spawnPointsOccupied -= 1;// after deleting the old mole schedule a respawn
// >%this.sceneGraph< is the level
echo("animation ended:" SPC %this.getAnimationName() );
echo("on mole:" @ %this.moleColor);
// update score
//if( %this.getAnimationName() $= ("animMoleWhacked" @ %this.moleColor) )
%this.scenegraph.incWhackedCount();
%this.sceneGraph.schedule( 1500, "spawnMole");
%this.safeDelete();
} else
if( %this.getAnimationName() $= ("animMoleDiveIn" @ %this.moleColor) ) {
%this.scenegraph.incMissedCount();
}//if
}//F
Instead of what is given, then it works.
Also, in the example, Scenegraph should be scenegraph, but if you take my code you'll be fine.
It took me a long while to figure out why the animations had to be named by color, if they were already on the mole, but I did figure it out, so I pass that along:
All the moles are based off a SINGLE sprite, which contains green, red and lilac frames for the moles and animations. Therefore, in order to trigger the "green dive in" you have to always tell it it is a 'green' mole. I would have recommended making 3 sprites for red, green, and purple just for the sake of the tutorial and clarity.
About the author
#2
I believe the point in using a single bitmap for the moles was actually part of the tutorial, to show you that you can and how to do it. Most of the other tutorials have everything split into a single image file per-animation or per-image and don't really use the ImageMap concept of multiple images or animations being available from within a single bitmap.
From an RPG perspective, such as RPG Maker XP, most of the graphics made available for this system are character sets which contain 4+ characters on a 'sheet' (image) with full animations for east/west/north/south movements and sometimes even fighting, which eventually gets broken into a series of animations and characters ... knowing how to do this is educational, in my opinion.
Make sure that endScreen.gui is exec()'d in your game.cs or your main.cs and restart the engine.
08/17/2006 (7:52 am)
Andrew,I believe the point in using a single bitmap for the moles was actually part of the tutorial, to show you that you can and how to do it. Most of the other tutorials have everything split into a single image file per-animation or per-image and don't really use the ImageMap concept of multiple images or animations being available from within a single bitmap.
From an RPG perspective, such as RPG Maker XP, most of the graphics made available for this system are character sets which contain 4+ characters on a 'sheet' (image) with full animations for east/west/north/south movements and sometimes even fighting, which eventually gets broken into a series of animations and characters ... knowing how to do this is educational, in my opinion.
Also, er.. I cannot access my endScreen.gui in the editor anymore. How do I open a gui in there?
Make sure that endScreen.gui is exec()'d in your game.cs or your main.cs and restart the engine.
#3
Yes, I see your point, it's just a jump and there's no clues how to get there. It was only my prior knowledge of other systems that allowed me to figure it out after a day or two. That's one reason I post, so folks as confused as I was get sped along.
08/18/2006 (8:36 am)
Yes, of course it is.Yes, I see your point, it's just a jump and there's no clues how to get there. It was only my prior knowledge of other systems that allowed me to figure it out after a day or two. That's one reason I post, so folks as confused as I was get sped along.
#4
Yeah, I am sorting posting quite a bit myself just to let others see where I'm going with things. I figure if I find a problem, I'll post about it, and if I have a solution, post that as well.
As for your "Yes, of course it is.", I assume you are responding to my statement about the endScreen.gui -- I read in a previous topic that exec'ing the gui was required and was simply just passing the information along -- I had the same GUI 'disappearance' issue as you appear to be having, but resolved it with this method.
08/18/2006 (5:17 pm)
Andrew,Yeah, I am sorting posting quite a bit myself just to let others see where I'm going with things. I figure if I find a problem, I'll post about it, and if I have a solution, post that as well.
As for your "Yes, of course it is.", I assume you are responding to my statement about the endScreen.gui -- I read in a previous topic that exec'ing the gui was required and was simply just passing the information along -- I had the same GUI 'disappearance' issue as you appear to be having, but resolved it with this method.
Torque Owner Quest Johnny
I found some more problems in the Timer section, but they were also correctable: (but maybe the tutorial needs updated)
It's missing a line:
$MOLE_LEVEL::timePerGame = 30;
in moleLevel.cs
ps, both of my placed bitmaps have grey rectangles around them in the actual game.. is this going to happen with every placed bitmap?
Also, er.. I cannot access my endScreen.gui in the editor anymore. How do I open a gui in there?