Recent posts by thegamemaker777 on Kongregate

Flag Post

Topic: Game Programming / Timer Spawning Multiple Enemy's?

@Draco, My spelling is poor. :P

 
Flag Post

Topic: Game Programming / Timer Spawning Multiple Enemy's?

Cool, thank you both for the advice. :)

 
Flag Post

Topic: Game Programming / Timer Spawning Multiple Enemy's?

Ahh yes! Thats a good idea :D

Much more efficient then timers and less code.
Thank you. :)

 
Flag Post

Topic: Game Programming / Timer Spawning Multiple Enemy's?

Hey guys, im in the middle of creating my first full Flash game. At the moment im dealing with enemy’s. I had it setup so they spawned randomly, but i dont really like that, as some levels will be to easy or too hard leaving the game luck based.

I then decided I could use timers and change them up or down to effect spawn rates for each level. Now for my question; Is running and firing a timer event for every enemy(10+ of them) efficient? I dont want to be inefficient and it seems weird to have to create 10 piece’s of close the same code over and over again for each enemy.

Any help/suggestions welcome, thank you.

 
Flag Post

Topic: Game Programming / Cannot access a property or method of a null object reference?[AS3]

Hey guys I fixed it with this: http://www.developphp.com/tutorial_read.php?tid=21 thank you both very much you helped me alot!!!! :)

 
Flag Post

Topic: Game Programming / Cannot access a property or method of a null object reference?[AS3]

OK, how can I fix this?

 
Flag Post

Topic: Game Programming / Cannot access a property or method of a null object reference?[AS3]

Thank you for the suggestion, I figured out it’s talking about this line of code: Key.initialize(stage);
But it was working fine before? Here is the key class:

/*
This class get initialized in the Constructor of the Game class.
This class manages basic key presses, user input.
You can just use this class by calling: Key.isDown(Keyboard.LEFT) from other classes like in AS2.0.
*/

package 
{
    
    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.KeyboardEvent;

    public class Key {
        
        private static var initialized:Boolean = false;
        private static var keysDown:Object = new Object();  // stores key codes of all keys pressed

        public static function initialize(stage:Stage) {
            if (!initialized) {
                // assign listeners for key presses and deactivation of the player
                stage.addEventListener(KeyboardEvent.KEY_DOWN, keyPressed); //Debug mode says error comes here
                stage.addEventListener(KeyboardEvent.KEY_UP, keyReleased);
                stage.addEventListener(Event.DEACTIVATE, clearKeys);
                
                // mark initialization as true so redundant
                // calls do not reassign the event handlers
                initialized = true;
            }
        }
        
		
        public static function isDown(keyCode:uint):Boolean 
		{
            return Boolean(keyCode in keysDown); 
        }
        
		
        private static function keyPressed(event:KeyboardEvent):void {
            keysDown[event.keyCode] = true;
        }
        

        private static function keyReleased(event:KeyboardEvent):void {
            if (event.keyCode in keysDown) {
                delete keysDown[event.keyCode];
            }
        }
        

        private static function clearKeys(event:Event):void {
            // clear all keys in keysDown since the player cannot detect keys being pressed or released when not focused
            keysDown = new Object();
        }
    }
} 

Thanks for your time. :)

 
Flag Post

Topic: Game Programming / Cannot access a property or method of a null object reference?[AS3]

Hi guys i have followed the AS3 shootorials and am now expanding on it, I am currently adding upgrades, but every thin was working just fine until I added the code to show the upgrade menu now it gives me this error: TypeError: Error #1009: Cannot access a property or method of a null object reference.
at Key$/initialize()
at Game()

I changed all the code back to the way it was before when it was working but it still give’s me the error, an Im pretty new to AS3 so I can’ figure it out. Here is my code(Note: the commented out code is the code that I added for the upgradeMenu)

package{

	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.utils.Timer;
	import flash.text.TextField;
	import flash.text.TextFormat;
	
	public class Game extends MovieClip
	{
	    static var ship:MovieClip;
		static var enemyShipTimer:Timer;
		static var medEnemyTimer:Timer;
		static var scoreText:TextField;
		static var score:Number;
		static var healthMeter:HealthMeter;
		static var gameOverMenu:GameOverMenu;
		static var pauseButton:PauseButton;
		static var startMenu:StartMenu;
		//static var upgradeMenu:UpgradeMenu;
		static var gameLevel:int;
		static var levelTime:Timer;
		static var timeVal:int;
		
		static var enemySpeed:Number;
		static var enemyHealth:Number;
		static var enemyShoot:Number;
		static var medEnemySend:Boolean;
		static var medEnemySpeed:int;
		static var ispaused:Boolean;
		
		var tempSpeed:Number;
		
		function Game()
	   {
		Key.initialize(stage);
		ship = new Ship();
		ship.x = 50;
		ship.y = 175;
		ship.visible = false;
		addChild(ship);
		
		ispaused = false;
		tempSpeed = 0;
		enemySpeed = 5;
		enemyHealth = 1;
		enemyShoot = 2500;
		medEnemySend = false;
		medEnemySpeed = 3;
		
		pauseButton = new PauseButton();
		pauseButton.x = 25;
		pauseButton.y = 300;
		pauseButton.visible = true;
		pauseButton.addEventListener("mouseUp", PauseUnPause);
		addChild(pauseButton);
		
		timeVal = 5000;
		levelTime = new Timer(timeVal);
		levelTime.addEventListener("timer", advLevel);
		
		enemyShipTimer = new Timer(1000);
		enemyShipTimer.addEventListener("timer", sendEnemy);
	    //enemyShipTimer.start();
		
		medEnemyTimer = new Timer(5000);
		medEnemyTimer.addEventListener("timer", sendMedEnemy);
		
		gameLevel = 1;
		
		scoreText = new TextField();
		scoreText.x = 300;
		scoreText.text = String(0);		
		scoreText.visible = false;
		addChild(scoreText);
		
		var scoreFormat = new TextFormat("Comic Sans MS", 20, 0x000000);
        scoreText.setTextFormat(scoreFormat); 
		
		healthMeter = new HealthMeter();
		healthMeter.x = 10;
		healthMeter.y = 10;
		healthMeter.visible = false;
		addChild(healthMeter);
		
		gameOverMenu = new GameOverMenu();
		gameOverMenu.x = 300;
		gameOverMenu.y = 175;
		addChild(gameOverMenu);
		gameOverMenu.visible = false;
		gameOverMenu.playAgainButton.addEventListener("mouseDown", newGame);
		gameOverMenu.playAgainButton.buttonMode = true;
		
		/*upgradeMenu = new UpgradeMenu();
		upgradeMenu.x = 50;
		upgradeMenu.y = 5;
		addChild(upgradeMenu);
		upgradeMenu.visible = false;
		upgradeMenu.resumeButton.addEventListener("mouseUp", advLevel);
		*/
		
		startMenu = new StartMenu();
        startMenu.x = 0;
        startMenu.y = 0;
        addChild(startMenu);
        startMenu.startButton.addEventListener("mouseDown", newGame);
		startMenu.startButton.buttonMode = true;
		startMenu.creditsButton.buttonMode = true;
		resetScore();
	
       }
	      
		  static function gameOver()
		  {
	       gameOverMenu.visible = true;
	       enemyShipTimer.stop();
	       for(var i in EnemyShip.list)
		   {
		    EnemyShip.list[i].kill();
	       }
		   for(var j in MedEnemy.list)
		   {
		    MedEnemy.list[j].kill();
		   }
          }
		 
		 function PauseUnPause(e:Event)
		  {
		    if(ispaused == false)
			{
    		 ispaused = true;
		     pauseGame();
		    }
		    else
		    {
		     ispaused = false;
		     unPauseGame();
		    }
		  }
		  
function newGame(e:Event){
	gameLevel = 1;
	enemyHealth = 1;
	enemySpeed = 5;
	enemyShoot = 2500;
	gameOverMenu.visible = false;
	startMenu.visible = false;
	ship.visible = true;
	healthMeter.visible = true;
	scoreText.visible = true;
	ship.x = 50;
	ship.y = 175;
	ship.takeDamage(-ship.maxHealth + ship.health);
	ship.addEventListener("enterFrame", ship.move);
	resetScore();
	enemyShipTimer.start();
	timeVal = 5000;
	levelTime.delay = timeVal;
	levelTime.start();
}
  function pauseGame()
  {
	enemyShipTimer.stop();
	medEnemyTimer.stop();
	levelTime.stop();
	tempSpeed = enemySpeed;
	enemySpeed = 0;
	Ship.velocity = 0;
  }
  
   function unPauseGame()
  {
	enemyShipTimer.start();
	medEnemyTimer.start();
	levelTime.start();
	enemySpeed = tempSpeed;
	Ship.velocity = 10;
  }

		function sendEnemy(e:Event)
		{
			var enemy = new EnemyShip();
			stage.addChild(enemy);
		}
		
		function sendMedEnemy(e:Event)
		{
		var enemy2 = new MedEnemy();
		stage.addChild(enemy2);
		
		}
		
		static function updateScore(points)
		{
		 score += points;
		 scoreText.text = String(score);
		}
		
		static function resetScore()
		{
			score = 0;
			scoreText.text = String(score);
		}
		
		
		function advLevel(e:Event)
		{
		    unPauseGame();
		    //upgradeMenu.visible = false;
	        gameLevel += 1;	
		    advEnemys();
			levelTime.delay = timeVal;
			levelTime.start();
		}
		
		function advEnemys()
		{
		if(gameLevel < 5)
		{
		  enemySpeed  += 0.2;
          enemyHealth += 0.2;
		  gameLevel += 1;
		  enemyShoot -= 500;
		    if(enemyShoot <= 1500)
		    {
		    enemyShoot = 1500;
		    }
		 }
		 
		 if(gameLevel > 5)
		 {
		     if(gameLevel < 10)
		     {
			
		      medEnemySend = true;
			  medEnemyTimer.delay = 5000;
      		  medEnemyTimer.start();
		     }
		 }
		  
		}
	
		
	}
	
}

I hope somebody can help me, thank very much. :)

 
Flag Post

Topic: Game Programming / ActionScript 2.0 Tutorial needed.

Try this: http://www.tutorialsphere.com/tutorials/flash/games :)

 
Flag Post

Topic: Game Programming / Custom Cursor.

Well Im pretty much a noob, but couldn’t you have a variable like customMouse = true if your in that frame then customMouse = false if your in another frame?

 
Flag Post

Topic: Game Programming / AS3 Tutorials???

yeah that one looks good, if I get time today I will start on it. Thank you =]

 
Flag Post

Topic: Game Programming / Adobe Flash Cs3 Question (very noobish)

Well if your using CS4 you can just double click the symbol then it will take you into is frame deal(or whatever) then just edit it from there with the tools on the right or right click it(while sill in the frame) and and there should be a button that says edit with GIMP or PhotoShop depending on what you default editor is. That should do it, Hope I helped. :)

 
Flag Post

Topic: Game Programming / AS3 Tutorials???

Wow your right even says AS3 right under them sorry my mistake, Thank you. :)

 
Flag Post

Topic: Game Programming / AS3 Tutorials???

@UnkownGuardian thx but I have done those already and there AS2.

@lord_azaral looks good I start using them thx. :)

 
Flag Post

Topic: Game Programming / AS3 Tutorials???

Does anyone know GOOD AS3 tutorials thats a series taking you from beginner to advanced? I have been trying to learn Flash for the last 3 days and have learned absolutely NOTHING, all the tutorials are either random(not a series just random how-to’s) or no good and it’s really starting to irritated me, I really want to learn this but nothing is working :(.

BTW I am pretty ok programmer in C#.NET and could get around in VB.NET also so Im not a total noob in the whole programming thing.

Thanks, Tanner. =]

 
Flag Post

Topic: Game Programming / Adding badges to my game? [SOLVED]

OK, Of course as soon as I post this I find what I’m looking for here: http://www.kongregate.com/developer_center/docs/statistics-api-tips

 
Flag Post

Topic: Game Programming / Adding badges to my game? [SOLVED]

How do I add badges to my game? do I use one of those API’s?

 
Flag Post

Topic: Game Programming / Rotating and shooting towards mouse.

Yep Im not to shabby in the .NET programing languages so I think I will be able to get this learned sort of easily its just all the code in the clip and class with different layers and timeline frame is a a lot different from what Im used to so it will take a little bit to get used to, but I am determent to learn it. ;)

 
Flag Post

Topic: Game Programming / How Do I make Levels? [SOLVED]

Well mine will be played with keyboard so now worry’s about that although I could have the option of a mouse game but anyway yes I will once I get the main features done add some originality to it. =]

 
Flag Post

Topic: Game Programming / Rotating and shooting towards mouse.

Yeah I don’t really understand but I will start to learn AS3.

 
Flag Post

Topic: Game Programming / Should I Code In Clip Or In Class?

Yeah thats all the code but is in the clip not the class or whatever.

 
Flag Post

Topic: Game Programming / Rotating and shooting towards mouse.

OK Im making a game where you have a gun that rotates with the mouse then when left click you shoot a bullet towards mouse, so I far I got the gun to rotate with this: " onClipEvent (enterFrame) { var radians = Math.atan2(root._ymouse-this.y, root.xmouse-this.x); var degrees = (radians/Math.PI)*180; this.rotation = degrees; } " inside the timeline, but I can’t figure out how to make the bullet move towards mouse I know how to make the bullet apear on mouse click but not move to mouse plz help im a noob(I started to learn Flash two days ago). =)

 
Flag Post

Topic: Game Programming / How Do I make Levels? [SOLVED]

OK cool And I could do this whit pretty much any type of lvl so Thanks ppl. =]

 
Flag Post

Topic: Game Programming / Should I Code In Clip Or In Class?

Well Ive been using AS2, but lets say I have this code in the timeline [code]onClipEvent (enterFrame) { var radians = Math.atan2(root._ymouse-this.y, root.xmouse-this.x); var degrees = (radians/Math.PI)*180; this.rotation = degrees; }[/code] Which makes a MC rotate towards mouse, but if I put that into a class instead of timeline I get an error why?

 
Flag Post

Topic: Game Programming / Should I Code In Clip Or In Class?

Should I Code In Clip Or In Class(that’s what you would call in with C#(IDK if its the same name :P)) Because in the shootorials they go through the class things but most the stuff online go’s into the clip. Is one way better than the other or do you pretty much just use both?

Thanks, Tanner.