Recent posts by crapageddon on Kongregate

Flag Post

Topic: Kongregate Labs / Shootorial #6 Health bar wont work

There were posts at the bottom of the actual tutorial page that solved this issue for me.

 
Flag Post

Topic: Kongregate Labs / Background Music Looping problem

nobody?

 
Flag Post

Topic: Game Programming / scope question

In this code, is ‘points’ a value passed in that will only exist:
a – within the scope of this function?
b – will cease to exist at the end of the functions execution?

function updateHealth(points)  
	{
		health += points;  
		if(health < 1) //GAME OVER
		{
			health = 0;
			_root.gameOverMenu._visible = true;
			explode();
		}
		_root.healthMeter.bar._xscale = health;
	}

 
Flag Post

Topic: Kongregate Labs / Background Music Looping problem

My background music is looping repeatedly so that it creates an echo of noise. Pretty sure this is because it’s in ‘OnEnterFrame’. Is there a way to make sure your BG music plays through once, before repeating. I followed the method in lesson 8 but they don’t show you where in the code they placed this particular bit of code. Ideas? Suggestions?

 
Flag Post

Topic: Game Programming / Shootorial #6 - Health Bar & Score not working

This turned out to be a 2 part problem:

HEALTH BAR
I added “health = 100” to the onLoad function of ship. That fixed the health bar issue.

SCORE TOGGLE
If you don’t CHECK the box in ‘embed’ for 0-9 characters, it will not include them. I had only highlighted the item and clicked OK. I believe the reason it did what it did – is that it only had the binary characters 1 and 0 – though I’m not totally sure. Either way, this fixed it.

Hope this helps someone else.

 
Flag Post

Topic: Game Programming / Shootorial #6 - Health Bar & Score not working

Not sure if it matters – I’m using CS5.5

 
Flag Post

Topic: Game Programming / Shootorial #6 - Health Bar & Score not working

I scrubbed the tutorial for the past 2 hours and all my code/instances are correct as far as I can tell. Issues:

- Health bar will not go down at all.
- Score toggles between 0,00,100. I can shoot OR collide into enemies.

 
Flag Post

Topic: Kongregate Labs / Shootorial #6 Health bar wont work

Same problem here too.

 
Flag Post

Topic: Kongregate Labs / New Shootorial

Second that emotion.

 
Flag Post

Topic: Kongregate Labs / Health bar not working, other threads not helping.

I’m having the same problem.

 
Flag Post

Topic: Game Programming / Ch6 Shootorial: Points = Local var?

Cool. I thought that’s what it was but didn’t know for sure. So when say ‘local’ does that refer to anything inside that particular class, or that particular scope?

 
Flag Post

Topic: Game Programming / Ch6 Shootorial: Points = Local var?

In chapter 6, I enter the following function (below), but it looks like they both have a points var. My question is, are they both local var’s to each respective function? I don’t see the var ‘points’ declared anywhere else in the class ship so it must be right?

//SCORING
	function updateScore(points)  //??? where does 'points' var come from? Is it being initiated here?
	//**anywhere you want to - you can update the score with _root.ship.updateScore(50);  - or whatever # points.
	{
		score += points;   
		_root.scoreText.text = score;
	}
		
	function resetScore()
	{
		score = 0;
		_root.scoreText.text = score;
	}
	
	//HEALTH
	function updateHealth(points)
	{
		health += points;  // ?? is 'points' a local var? It's used above in updateScore function too.
		_root.healthMeter.bar._xscale = health;
	}

 
Flag Post

Topic: Game Programming / Ch5-Shootorial: How does it find the function?

Awesomeness. Thank you.

 
Flag Post

Topic: Game Programming / Ch5-Shootorial: How does it find the function?

Sorry, not sure why the tags didn’t work above:

class Missile extends MovieClip

{

	var speed;
function onLoad() 
{
speed = 24;
}

function onEnterFrame() 
{
_x += speed;

//Check for Collision at frame rate. 
for(var i in _root.ship.enemies) 
{
if(this.hitTest( _root.ship.enemies[i])) 
{
this.removeMovieClip(); 
_root.ship.enemies[i].explode(); //how is this finding the explode function???
}
}

//removes it when off screen
if(_x > 700) // 
{
this.removeMovieClip();
}
}

}
 
Flag Post

Topic: Game Programming / Ch5-Shootorial: How does it find the function?

In the following code, how does this line find the function explode? Explode doesn’t exist inside the ship class but it looks like it’s trying to find the explode function inside an enemies array:

_root.ship.enemies[i].explode()

CODE

class Missile extends MovieClip
{
var speed;

function onLoad()
{
speed = 24;
}

function onEnterFrame()
{
_x += speed;

//Check for Collision at frame rate.
for(var i in _root.ship.enemies)
{
if(this.hitTest( _root.ship.enemies[i]))
{
this.removeMovieClip();
_root.ship.enemies[i].explode(); //how is this finding the explode function???
}
}

//removes it when off screen
if(_x > 700) //
{
this.removeMovieClip();
}
}

}

 
Flag Post

Topic: Game Programming / Enemies being hit sporadically

^ FYI – my game is running at 24fps, not 30 – hence the change in timing.

 
Flag Post

Topic: Game Programming / Enemies being hit sporadically

 
///////////////SHIP CLASS///////////////////////
class Ship extends MovieClip
{
	var velocity;
	var shootLimiter;
	var enemyTimer;
	var enemies;
	
	function onLoad()
	{
		velocity = 15;
		shootLimiter = 0;
		enemyTimer = 0;
		enemies = [];
	}
	
	function onEnterFrame()
	{
		
	        shootLimiter += 1; //the way this limiter works is as a counter. If it's over the time limit it wont shoot.
		
		if( Key.isDown(Key.RIGHT) )
		{
			_x = _x + velocity;
		}
		
		if ( Key.isDown(Key.LEFT) )
		{
			_x = _x - velocity;
		}
		
		if ( Key.isDown(Key.UP) )
		{
			_y = _y - velocity;
		}
		
		if ( Key.isDown(Key.DOWN) )
		{
			_y = _y + velocity;
		}
		
		if ( Key.isDown(Key.SPACE) && shootLimiter > 8 )
		{
			var missile = _root.attachMovie( "Missile" , "Missile" + _root.getNextHighestDepth(), _root.getNextHighestDepth() );
			missile._x = _x + 50;  //still applying the x and y of THIS (ship) class.
			missile._y = _y + 2;
			shootLimiter = 0;
		}
		
		//ENEMY TIMER  ****adds a new enemy every 2 sec
		enemyTimer +=1; //every frame it increments by 1.
		if(enemyTimer > 48) //conditional...waits until you go over # frames.
		{
			enemyTimer = 0; //reset timer
			_root.attachMovie("EnemyShip", "EnemyShip"+_root.getNextHighestDepth(), _root.getNextHighestDepth());
			
			//ADD ENEMIES TO LOG
			var enemy = _root.attachMovie("EnemyShip", "EnemyShip" + _root.getNextHighestDepth(), _root.getNextHighestDepth()); 
			enemies.push(enemy);
		}
		
	}
}

///////////////ENEMY SHIP CLASS///////////////////////

class EnemyShip extends MovieClip
{
	var speed;
	var shootLimiter;
	var enemyTimer;
	var shootTimer
	
	function onLoad()
	{
		_x = 700; //width is 600, so 700 lets it bleed.
		_y = Math.random()*300;  //swf is 300 pixels tall, so we keep it between 0 and 300. Creates a random # between 0 and 1, then multiplies by 300. tweak for bleeds ex: _y = Math.random()*200 + 50;
		speed = Math.random()*5 +5;  //randomizes enemy speed to # between 5 and 10. Rand of 0-1, * 5 plus five to ensure it's at least 5.
		shootTimer = 0;
	}
	
	function onEnterFrame()
	{
		_x -= speed; //by subtracting it makes the ship move that many pixels Left.
		if(_x < -100) // If the ship is over 100 pix off the left, we know it's safe to remove it (out of view).
		{
			this.removeMovieClip();
		}

		//Collision Detect
		if(this.hitTest(_root.ship))
		{
			explode();
		}
		
		//ShootTimer
		shootTimer +=1;
		if(shootTimer > 24)  //everytime it goes over the frame rate, do this...
		{
			shootTimer = 0;   //reset to zero
			var missile = _root.attachMovie("EnemyMissile","EnemyMissile" + _root.getNextHighestDepth(),_root.getNextHighestDepth());   //create a new missile var of "EnemyMissile").
			missile._x = _x - 50;  //setting X
			missile._y = _y + 2;   //setting y
		}
		
	}
	
	//explode function
		function explode()
		{
			//add explosion clip to the XY of the enemy ship
			var explosion = _root.attachMovie( "Explosion", "Explosion" + _root.getNextHighestDepth(),_root.getNextHighestDepth() );
			explosion._x = _x;
			explosion._y = _y;
			this.removeMovieClip();
		}
}


///////////////MISSILE CLASS///////////////////////
class Missile extends MovieClip
{
	var speed;
	
	function onLoad()
	{
		speed = 24;
	}
	
	function onEnterFrame()
	{
		_x += speed;
		
		//Check for Collision at frame rate. ***Using "for..in" loop to iterate through array.
		for(var i in _root.ship.enemies)     //enemies referring to var enemies in ship class (list).
		{
			if(this.hitTest( _root.ship.enemies[i]))    //the i is iterating through all the existing # of ships in the array.
			{
				this.removeMovieClip();    //removes missile
				_root.ship.enemies[i].explode();  //how is this finding the explode function???
			}
		}
		
		//removes it when off screen
		if(_x > 700) // most efficient at screen size (600). I'm making it an extra 100 so it can bleed off edge.
		{
			this.removeMovieClip();
		}
	}

}

 
Flag Post

Topic: Game Programming / Enemies being hit sporadically

Here are the three codes that involve collision with the ship missile.

////////////////////////////////////////////////

class Ship extends MovieClip
{
var velocity;
var shootLimiter;
var enemyTimer;
var enemies;

function onLoad()
{
velocity = 15;
shootLimiter = 0;
enemyTimer = 0;
enemies = [];
}

function onEnterFrame()
{

shootLimiter += 1;

if( Key.isDown(Key.RIGHT) )
{
_x = _x + velocity;
}

if ( Key.isDown(Key.LEFT) )
{
_x = _x – velocity;
}

if ( Key.isDown(Key.UP) )
{
_y = _y – velocity;
}

if ( Key.isDown(Key.DOWN) )
{
_y = _y + velocity;
}

if ( Key.isDown(Key.SPACE) && shootLimiter > 8 )
{
var missile = _root.attachMovie( “Missile” , “Missile” + _root.getNextHighestDepth(), root.getNextHighestDepth() );
missile.
x = x + 50; //still applying the x and y of THIS (ship) class.
missile.
y = _y + 2;
shootLimiter = 0;
}

//ENEMY TIMER *adds a new enemy every 2 sec
enemyTimer =1;
if(enemyTimer > 48) //conditional…waits until you go over # frames.
{
enemyTimer = 0; //reset timer
_root.attachMovie(“EnemyShip”, “EnemyShip”
_root.getNextHighestDepth(), _root.getNextHighestDepth());

//ADD ENEMIES TO LOG
var enemy = _root.attachMovie(“EnemyShip”, “EnemyShip” + _root.getNextHighestDepth(), _root.getNextHighestDepth());
enemies.push(enemy);
}

}
}

////////////////////////////////////////////////

class Missile extends MovieClip
{
var speed;

function onLoad()
{
speed = 24;
}

function onEnterFrame()
{
_x += speed;

//Check for Collision at frame rate. ***Using “for..in” loop to iterate through array.
for(var i in _root.ship.enemies) //enemies referring to var enemies in ship class (list).
{
if(this.hitTest( _root.ship.enemies[i])) //the i is iterating through all the existing # of ships in the array.
{
this.removeMovieClip(); //removes missile
_root.ship.enemies[i].explode(); //how is this finding the explode function???
}
}

//removes it when off screen
if(_x > 700) // most efficient at screen size (600). I’m making it an extra 100 so it can bleed off edge.
{
this.removeMovieClip();
}
}

}

///////////////////////////////////////////////

class EnemyShip extends MovieClip
{
var speed;
var shootLimiter;
var enemyTimer;
var shootTimer

function onLoad()
{
_x = 700; //width is 600, so 700 lets it bleed.
_y = Math.random()300; //swf is 300 pixels tall, so we keep it between 0 and 300. Creates a random # between 0 and 1, then multiplies by 300. tweak for bleeds ex: _y = Math.random()200 + 50;
speed = Math.random()*5 +5; //randomizes enemy speed to # between 5 and 10. Rand of 0-1, * 5 plus five to ensure it’s at least 5.
shootTimer = 0;
}

function onEnterFrame()
{
x -= speed; //by subtracting it makes the ship move that many pixels Left.
if(
x < -100) // If the ship is over 100 pix off the left, we know it’s safe to remove it (out of view).
{
this.removeMovieClip();
}

//Collision Detect
if(this.hitTest(_root.ship))
{
explode();
}

//ShootTimer
shootTimer +=1;
if(shootTimer > 24) //everytime it goes over the frame rate, do this…
{
shootTimer = 0; //reset to zero
var missile = _root.attachMovie(“EnemyMissile”,“EnemyMissile” + root.getNextHighestDepth(),_root.getNextHighestDepth()); //create a new missile var of “EnemyMissile”).
missile.
x = x – 50; //setting X
missile.
y = _y + 2; //setting y
}

}

//explode function
function explode()
{
//add explosion clip to the XY of the enemy ship
var explosion = _root.attachMovie( “Explosion”, “Explosion” + root.getNextHighestDepth(),_root.getNextHighestDepth() );
explosion.
x = x;
explosion.
y = _y;
this.removeMovieClip();
}
}

 
Flag Post

Topic: Game Programming / Enemies being hit sporadically

Also…all the enemies are blowing up when I touch them, even if the missile goes right through them.
Touch collision = 100% active
Missile collission = 30-50% active

 
Flag Post

Topic: Game Programming / Enemies being hit sporadically

Both the missile and enemy ship are 100 pixels wide.
The missiles are moving at a speed of 5-10 pixels per frame (randomly chooses rate).

Is the collision detecting anything within the symbol frame (blue box), or is it only detecting the very center point? Center point seems like it would be very hard to hit.

Does this help figure out the problem?

 
Flag Post

Topic: Game Programming / Enemies being hit sporadically

I just finished Shootorial 5. The enemies I fire at only die sporadically. Sometimes the missile clearly goes right through them. Any idea why? It doesn’t do this for the example files.

 
Flag Post

Topic: Game Programming / Class::Symbol::Stage - Relationship question.

When I create a symbol “Truck”, I have the options that pop up for a movie clip. I give it the identifier “Truck”, as well as a class name of “Truck”. Then, I can go on to create a class named Truck.

My question is:
Which thing is the class using to talk to the symbol? The class name, or the identifier? I’m trying to understand the fundamental difference between these, and thus how they communicate between the class, symbol, and stage. Why do you need both and what does each actually do?