Recent posts by holgeir564 on Kongregate

Subscribe to Recent posts by holgeir564 on Kongregate

avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Design / Replayability

Some super hard games give me the replayability because when I come back to such a game it is still hard. The worlds hardest game is a good exaple of this. I have never really beaten it but I come back to it again and again beating the same levels for fun. Do you feel the same about hard games or do they just frustrate you?

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Better code for mass Buttons (solved)

Thanks for the tip it worked :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Better code for mass Buttons (solved)

There has to be a better way than this to make multiable button EventListener (@case “PlayMenu”):


switch (useMenu)
			{
				case "InsMenu" :
					insMenu = new InsMenu();
					addChild(insMenu);
					insMenu.BackButton.addEventListener(MouseEvent.CLICK,onBackButtonClick);
					break;
				case "PlayMenu" :
					playMenu = new PlayMenu();
					addChild(playMenu);
					playMenu.BackButton.addEventListener(MouseEvent.CLICK,onBackButtonClick);
					playMenu.Level1Button.addEventListener(MouseEvent.CLICK,onLevel1Click);
					playMenu.Level2Button.addEventListener(MouseEvent.CLICK,onLevel2Click);
					playMenu.Level3Button.addEventListener(MouseEvent.CLICK,onLevel3Click);
					playMenu.Level4Button.addEventListener(MouseEvent.CLICK,onLevel4Click);
					playMenu.Level5Button.addEventListener(MouseEvent.CLICK,onLevel5Click);
					playMenu.Level6Button.addEventListener(MouseEvent.CLICK,onLevel6Click);
					playMenu.Level7Button.addEventListener(MouseEvent.CLICK,onLevel7Click);
					playMenu.Level8Button.addEventListener(MouseEvent.CLICK,onLevel8Click);
					playMenu.Level9Button.addEventListener(MouseEvent.CLICK,onLevel9Click);
					break;
				case "MainMenu" :
					mainMenu = new MainMenu();
					addChild(mainMenu);
					mainMenu.PlayButton.addEventListener(MouseEvent.CLICK,onPlayButtonClick);
					mainMenu.InsButton.addEventListener(MouseEvent.CLICK,onInsButtonClick);
					break;
				default :
					trace("error #3: no menu found");
					break;
			}

Thanks in advance :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Having some #1009 problems

So here is my code:


package 
{
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.events.TimerEvent;
	import flash.utils.Timer;
	public class Enemy extends MovieClip
	{
		public var statx:Number;
		public var staty:Number;

		//misc vars
		public var typ:Number;//keeps track of what type clip is
		public var shoots:Boolean;
		public var shotRotation:Number;
		public var shotTimer:Timer;
		public var shot:Shot;
		public var xOffset:Number;//where shots spawn compared to clip posision
		public var yOffset:Number;//where shots spawn compared to clip posision

		//movent vars
		public var xspeed:Number;
		public var yspeed:Number;
		public function Enemy(statx,staty,typ)
		{
			x=statx;
			y=staty;
			this.typ=typ;
			gotoAndStop(typ);
			switch (typ)
			{
				case 1 :
					this.xspeed=-5;
					this.yspeed=0;
					this.shoots = false;
					break;
				case 2 :
					this.xspeed=-6;
					this.yspeed=0;
					xOffset = -(width/2);
					yOffset = 0;
					shotTimer = new Timer(1000);
					shotTimer.addEventListener(TimerEvent.TIMER,onShoot);
					shotTimer.start();
					break;
				default :
					trace("error #1: enemyType dose not exist");
					break;
			}
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		public function onAddedToStage(event:Event)
		{
			dispatchEvent(new Event("enemyCreated",true));
			stage.addEventListener(Event.REMOVED_FROM_STAGE,onRemoved);
		}
		public function onRemoved(event:Event)
		{
			shotTimer.stop();
		}
		public function onShoot(timerEvent:TimerEvent)//(##)
		{
			shot = new Shot(x+xOffset,y+yOffset,180);
			parent.addChild(shot);
		}
		public function onMove():void
		{
			x+= xspeed;
			y+= yspeed;
		}
	}
}

At (##) it spawns a shot which is shot by the enemy. The first enemy goes across the stage without anything happening. But when the second enemy goes on stage the output gives me this every time it shoots:


TypeError: Error #1009: Cannot access a property or method of a null object reference.
	at Enemy/onShoot()
	at flash.utils::Timer/_timerDispatch()
	at flash.utils::Timer/tick()

This error dose not show up when the onShoot function is empty. I don’t know what I am doing wrong :S

Thanks in advance :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] RemoveChild function :O

I got your point :) And it worked ;)

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] RemoveChild function :O

3.I see what you mean. Instead of like I have it you would have:


public function spawnShot(var shotX,var shotY,var shotRotation):void
{
	shot = new Shot(shotX,shotY,shotRotation);
	addChild(shot);
}

Is that right?

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] RemoveChild function :O

1.It works
2.It works
3.Not following you…?

(I’m new to AS3 so :D)

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] RemoveChild function :O

Thanks that worked :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] RemoveChild function :O

That little snippet of code is in the same object where I addChild shot. Here the whole thing is:


package 
{
	import flash.display.MovieClip;
	import flash.events.TimerEvent;
	import flash.events.Event;
	import flash.utils.Timer;
	import flash.events.KeyboardEvent;
	import flash.ui.Keyboard;
	public class GameScreen extends MovieClip
	{
		//defning movieClips
		public var player:Player;
		public var shot:Shot;

		//defining Timers
		public var fastTick:Timer;//fast timer which handels player movment and other stage movments

		//defining keyboard vars
		public var keyArray:Array=new Array;
		public var upKey:Boolean;
		public var downKey:Boolean;
		public var rightKey:Boolean;
		public var leftKey:Boolean;
		public var spaceKey:Boolean;

		//shot startposisions
		public var shotX:Number = 0;
		public var shotY:Number = 0;
		public var shotRotation:Number = 0;
		public function GameScreen()
		{
			addEventListener(Event.ADDED_TO_STAGE,onGetStage);

			player = new Player(100,100);
			addChild(player);

			fastTick = new Timer(10);
			fastTick.addEventListener(TimerEvent.TIMER,onFastTick);
			fastTick.start();
		}
		public function onFastTick(timerEvent:TimerEvent):void
		{
			//if key is up
			if (keyArray.indexOf(38) < 0)
			{
				upKey=false;
			}
			if (keyArray.indexOf(40) < 0)
			{
				downKey=false;
			}
			if (keyArray.indexOf(37) < 0)
			{
				leftKey=false;
			}
			if (keyArray.indexOf(39) < 0)
			{
				rightKey=false;
			}
			if (keyArray.indexOf(32) < 0)
			{
				spaceKey=false;
			}

			//if key is down
			if (keyArray.indexOf(38) >= 0)
			{
				upKey=true;
			}
			if (keyArray.indexOf(40) >= 0)
			{
				downKey=true;
			}
			if (keyArray.indexOf(37) >= 0)
			{
				leftKey=true;
			}
			if (keyArray.indexOf(39) >= 0)
			{
				rightKey=true;
			}
			if (keyArray.indexOf(32) >= 0)
			{
				spaceKey=true;
			}
			trace(keyArray);

			player.onMove(upKey,downKey,rightKey,leftKey,spaceKey);//this function lests the player know which keys are down and enables movment

			if (spaceKey == true)
			{
				spawnShot(player.x,player.y,90);
			}
			for (var i in Shot.shotz)
			{
				Shot.shotz[i].x += Shot.shotz[i].xspeed;
				Shot.shotz[i].y += Shot.shotz[i].yspeed;
				if (Shot.shotz[i].y>500||Shot.shotz[i].y<0||Shot.shotz[i].x<0||Shot.shotz[i].x>700)
				{
					removeChild(Shot.shotz[i]);
				}
			}

		}
		//spawns shots
		public function spawnShot(shotX,shotY,shotRotation):void
		{
			shot = new Shot(shotX,shotY,shotRotation);
			addChild(shot);
		}
		//Setup keys
		public function onGetStage(event:Event)
		{
			stage.addEventListener(KeyboardEvent.KEY_UP,removeKey);
			stage.addEventListener(KeyboardEvent.KEY_DOWN,addKey);

		}
		//adds keys that are down to keyArray
		public function addKey(e:KeyboardEvent):void
		{
			if (keyArray.indexOf(e.keyCode) < 0)
			{
				keyArray.push(e.keyCode);
			}
		}
		//removes keys that are not down from keyArray
		public function removeKey(e:KeyboardEvent):void
		{
			if (keyArray.indexOf(e.keyCode) >= 0)
			{
				keyArray.splice(keyArray.indexOf(e.keyCode),1);
			}
		}
	}
}

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] RemoveChild function :O

How do I then remove it?

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] RemoveChild function :O

This is my code:


for (var i in Shot.shotz)
			{
				Shot.shotz[i].x += Shot.shotz[i].xspeed;
				Shot.shotz[i].y += Shot.shotz[i].yspeed;
				if (Shot.shotz[i].y>500||Shot.shotz[i].y<0||Shot.shotz[i].x<0||Shot.shotz[i].x>700)
				{
					removeChild(Shot.shotz[i]);// (*)
				}
			}

At (*) I am trying to make the shot disappear, but flash traces:


ArgumentError: Error #2025: The supplied DisplayObject must be a child of the caller.
	at flash.display::DisplayObjectContainer/removeChild()
	at GameScreen/onFastTick()
	at flash.utils::Timer/_timerDispatch()
	at flash.utils::Timer/tick()

What am I doing wrong here?
Thanks in advance :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / Copy and pasting

Seems like a great program! But I have a mac and I can’t find it for mac :/

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / Copy and pasting

So this Christmas vacation I want to try to go bananas and program a lot. I also want get into good habits with my “mechanics” when programing. So I wanted to ask if you use copy paste (in your own code) when coding or do you type everything in by hand? If you have other tips they would be appreciated :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] When stuff is undefined (Solved)

Solved it! thanks :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] When stuff is undefined (Solved)

LoL I didn’t define currentLevel :P

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] When stuff is undefined (Solved)

This is my code, take note of (#) and (##):


package 
{
	import flash.display.MovieClip;
	public class Doors extends MovieClip
	{
		public var door:Door;

		public var currentLevel:Number;
		//Doorlevel vars where doors spawn and where they lead
		static var doorsLevel1:Array = [];
		static var doorsLevel2:Array = [];
		static var doorsArray:Array = [doorsLevel1,doorsLevel2];
		public function Doors(currentLevel)
		{
			defineDoorPlacement();
			makeDoors(currentLevel);
		}
		public function defineDoorPlacement():void
		{
			doorsLevel1 = [1,2,3];
			doorsLevel2 = [1,2,3];
		}
		public function makeDoors(currentLevel):void
		{
			trace(doorsArray[currentLevel-1]) // (#)
			var useLevel = doorsArray[currentLevel-1];
			trace(useLevel[1]); // (##)
		}
	}
}

At (#) it traces a empty array an at (##) it traces undefined. Why is everything so undefined!

Thanks in advance.

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Variable access (SOLVED)

Thanks! it worked! :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Variable access (SOLVED)

Is there a way to make a variable which you can access anywhere in your code?
In AS2 you could do _root.someVariable = 1010191238239412; :/
thanks in advance :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Variables between classes (SOVLED!)

It worked :D thanks.

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Variables between classes (SOVLED!)

I am a newbie to as3 so there is probably a simple answer to this question. I have these two classes (note: (#) and (##)):


package 
{
	import flash.display.MovieClip;
	public class Level extends MovieClip
	{
		public var tile:Tile;
		static var gameLevel:Array=[];
		public function Level()
		{
			defineLevels();
			makeLevel();
		}
		public function defineLevels():void
		{
			gameLevel[0]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
			gameLevel[1]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
			gameLevel[2]=[0,0,0,0,0,0,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1,1,1,1];



		}
		public function makeLevel():void
		{
			for (var i=0; i < gameLevel[0].length; i++)
			{
				for (var ii=0; ii < gameLevel.length; ii++)
				{
					if (gameLevel[ii][i] != 0)
					{
						var tile=new Tile(i * 20,ii * 20, gameLevel[ii][i]);
						addChild(tile);
						trace(tile.typ);//    (#)
					}
				}
			}
		}
	}
}

and:


package 
{
	import flash.display.MovieClip;
	public class Tile extends MovieClip
	{
		public var statx:Number = 0;
		public var staty:Number = 0;
		public var typ:Number;
		static var tiles = [];
		public function Tile(statx,staty,typ)
		{
			tiles.push(this);
			x = statx;
			y = staty;
			gotoAndStop(typ);
			trace(typ);//    (##)
		}
	}
}

At (##) it traces a valid number but at (#) it traces NaN. Why is that and how do I get a valid number?

Thanks in advance :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [As3] Array help!

hehe, me being dump :P Thanks :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [As3] Array help!

So here is my code (look out for (#) and (##)):


package 
{
	import flash.display.MovieClip;
	public class Level extends MovieClip
	{
		public var tile:Tile;
		static var gameLevel:Array=[];
		public function Level()
		{
			defineLevels();
			makeLevel();
		}
		public function defineLevels():void
		{
			gameLevel[0]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
			gameLevel[1]=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0];
			gameLevel[2]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[3]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[4]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[5]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[6]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[7]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[8]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[9]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[10]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[11]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
			gameLevel[12]=[0,0,0,0,1,1,1,1,1,1,1,1,1,1,1];
		}
		public function makeLevel():void
		{
			trace(gameLevel[2][5]); // (#)
			for (var i=0; i < 100; i++)
			{
				for (var ii=0; i < 100; i++)
				{
					trace(gameLevel[ii][i]) // (##)
					if (gameLevel[ii][i] == 1)
					{
						var tile=new Tile(i * 20,ii * 20);
						addChild(tile);
					}
				}
			}
		}
	}
}

At (#) it gives me 1 but at (##) it tells me that all the gameLevel is 0. That doesn’t make any sense!?!

Thanks in advance :D

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Design / Platform Game Enemies

I’m making a platforming game and I have been thinking lately about the types of enemies you could encounter in the game. Of course you have the obvious flying and ground enemies (and maybe water enemies). But what kind of movement of flying and ground enemies is both compelling and difficult to handle for the player?

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / [AS3] Character turnaround

This works! Thanks!

 
avatar for holgeir564 holgeir564 52 posts
Flag Post

Topic: Game Programming / my first game

Great job keep it up!