Recent posts by zero579911 on Kongregate

Subscribe to Recent posts by zero579911 on Kongregate

avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / What is causing my For Loop to fail?

My sprite sheet is 2048×2048, I’m not using the whole thing yet, I only took 15 sprites from the sprite sheet. And, thanks! It works.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / What is causing my For Loop to fail?

Hello, I have a very strange problem. For some reason, my for loop seems to fail when I push my class to an array; it stops on the 96th iteration.

Main.as

package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	import flash.text.TextField;
	import flash.utils.getTimer;
	
	[Frame(factoryClass="Preloader")]
	public class Main extends Sprite {
		// DISPLAY
		private var
		canvas:BitmapData,
		mySpriteArray:Vector.<MySprite> = new Vector.<MySprite>(),
		
		// SHOW FPS
		startTime:Number,
		framesNumber:Number = 0;
		
		public function Main():void {
			canvas = new BitmapData(480, 400, false, 0x000000);
			addChild(new Bitmap(canvas));
			
			startTime = getTimer();
			
			for (var i:int = 0; i < 200; ++i) {
				trace(i);
				mySpriteArray[i] = new MySprite();
				mySpriteArray[i].spritePoint.x = (Math.random() * 480);
				mySpriteArray[i].spritePoint.y = (Math.random() * 400);
			}
			
			addEventListener(Event.ENTER_FRAME, loop, false, 0, true);
		}
		
		private function loop(e:Event):void {
			var currentTime:Number = (getTimer() - startTime) / 1000;
			++framesNumber;
			
			if (currentTime > 1) {
				trace(int((framesNumber / currentTime) * 10.0) / 10.0);
				startTime = getTimer();
				framesNumber = 0;  
			}
			
			var mySprite:MySprite;
			
			canvas.lock();
			canvas.fillRect(canvas.rect, 0x000000);
			for (var i:int = 0, mySpriteArrayLength:int = mySpriteArray.length - 1; i < mySpriteArrayLength; ++i) {
				mySprite = mySpriteArray[i];
				mySprite.animate();
				canvas.copyPixels(mySprite.spriteBD, mySprite.spriteBD.rect, mySprite.spritePoint);
			}
			canvas.unlock();
		}
	}
}

MySprite.as

package {
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.MovieClip;
	import flash.geom.Point;
	import flash.geom.Rectangle;
	
	public class MySprite {
		[Embed(source = "SpriteSheet.png")] private var SpriteSheet:Class;
		
		public var
		spriteBD:BitmapData = new BitmapData(140, 130, true, 0x000000),
		spriteSheet:Bitmap = new SpriteSheet(),
		spriteAnimationArray:Vector.<BitmapData> = new Vector.<BitmapData>(),
		spritePoint:Point = new Point(0, 0),
		spriteAnimationIndex:int = 0,
		spriteZeroPoint:Point = new Point(0, 0);
		
		public function MySprite() {
			var bitmapData:BitmapData = new BitmapData(129, 121, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(671, 252, 129, 121), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(137, 117, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(800, 253, 129, 119), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 117, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(129, 495, 129, 117), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 112, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(129, 612, 129, 112), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 107, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(0, 833, 129, 107), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 104, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(258, 605, 129, 104), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 102, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(129, 829, 129, 102), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 103, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(387, 498, 129, 103), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 105, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(129, 724, 129, 105), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 109, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(258, 496, 129, 109), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 114, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(0, 719, 129, 114), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 118, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(0, 483, 129, 118), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 118, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(0, 601, 129, 118), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
			
			bitmapData = new BitmapData(129, 121, true, 0x000000);
			bitmapData.copyPixels(spriteSheet.bitmapData, new Rectangle(802, 132, 129, 121), spriteZeroPoint);
			spriteAnimationArray[spriteAnimationArray.length] = bitmapData;
		}
		
		public function animate():void {
			if (spriteAnimationIndex > spriteAnimationArray.length - 1) {
				spriteAnimationIndex = 0;
			}
			spriteBD.lock();
			spriteBD.fillRect(spriteBD.rect, 0x000000);
			spriteBD.copyPixels(spriteAnimationArray[spriteAnimationIndex], spriteAnimationArray[spriteAnimationIndex].rect, spriteZeroPoint);
			spriteBD.unlock();
			++spriteAnimationIndex;
		}
	}
}

Hopefully someone knows what the problem is.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / [AS3] [SOLVED] Converting Movieclip to Bitmap faster than just Movieclip?

Originally posted by NineFiveThree:
Originally posted by zero579911:

And also, I want to make everything by myself without using Frameworks, etc.

lol

._. Yes, I know that Adobe made the Classes themselves but I meant like Flixel, Startling and other frameworks. And what’s so funny about that.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / [AS3] [SOLVED] Converting Movieclip to Bitmap faster than just Movieclip?

I already know how to create one. It’s just my artist who doesn’t know how, but next game I guess he’ll start learning or something. He says blitting is a bit overkill, lol. :P However, this still clearly works, its faster than just using Movieclips. I’d prefer sprite sheets over this but again, my artist thinks it’s a bit overkill. All he has to do is export the Movieclip’s frames to a PNG file and make it into 1 big sprite sheet.

And also, I want to make everything by myself without using Frameworks, etc.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / [AS3] [SOLVED] Converting Movieclip to Bitmap faster than just Movieclip?

Nahh, I didn’t do cacheAsBitmap. What I did was make a class, made a variable to reference the MovieClip from the swc file (I’m using FlashDevelop) and then I drew every frame of the MC onto an Array. I then made a function to play through the whole Array so it animates. (I know I could’ve done it a different way; Example: Make the MC to stop on the next frame and then draw it to the canvas, but I wanted to do it this way since I’m making a game like this.) In my Main.as (not MC Class) I made a bitmapData(canvas) for the whole thing to draw on, then I made a for loop to make a bunch of MCs converted to bitmaps through my class, and then I finally copyPixel every MC’s bitmapData to the canvas.

If there’s a faster way then go ahead, tell me. I’ll be glad to change my way of MC → Bitmap Blitting so it’s even faster.

EDIT: Also, this is my first time testing anything at all. All I did was go on the internet, looked up ways on how to get your FPS and started testing.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / [AS3] [SOLVED] Converting Movieclip to Bitmap faster than just Movieclip?

Hello, if you guys are wondering about the answer, I’ve gotten it for you by testing it myself.

The MC contains 58 frames in total.

10 MC’s = 30 FPS
50 MC’s = 20 FPS
100 MC’s = 8-10 FPS
250 MC’s = 3 FPS

100 MC’s converted = Stable 30 FPS
250 MC’s converted = Stable 30 FPS
500 MC’s converted = Stable 20 FPS

This was tested on a 5 year old Laptop, results are going to vary with other computers. This shows that even if you are converting a Movieclip to a Bitmap, it is still going to be faster than just plain movieclips. However, memory usage increases higher with conversion instead of just plain MC’s. Also, the initial load of converting and adding it to the canvas is slower than the initial load of just adding MC’s to the stage.

TL;DR: Converting a Movieclip to a Bitmap IS faster than just using a plain Movieclip.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / Loading and preloading

If you use FlashDevelop, they actually have a Premade Preloader class, all you have to do is show, update, and then remove it.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / [AS3] [SOLVED] Converting Movieclip to Bitmap faster than just Movieclip?

Hello, would converting a Movieclip to a Bitmap faster than just using a plain Movieclip?

You would convert the Movieclip to a Bitmap dynamically and do a draw operation to draw the movieclip onto the bitmapData. Then, in your main canvas where everything is getting displayed, you would do

canvas.copyPixels(mcBitmapData, mcRectangle, mcPoint);

Performance wise, would this be faster than just using plain Movieclips? I know that this is slower blitting, (since you have to convert, draw, AND THEN copyPixels) but would this still be faster than using just movieclips? Also, if there’s a better way to convert and copy it to the canvas, please tell me.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / Bullet not shooting at target(player ship)?

Fixed it. All I had to do was change

megaBossDrone.rotation = angle(ship.x, ship.y, megaBossDrone.x, megaBossDrone.y);

to

megaBossDrone.rotation = angle(megaBossDrone.rotation);

and change

The bullet to

package {
	import flash.display.MovieClip;
	import flash.events.Event;
	
	/**
	 * ...
	 * @author zero579911
	 */
	public class MegaBossDroneBullet extends MovieClip {
		//DISPLAY
		private var 
		missle:MovieClip = new MegaBossDroneBulletMC,
		
		//PROPERTIES
		radians:Number = 0,
		speed:Number = 10;
		
		public function MegaBossDroneBullet(rad:Number) {
			radians = rad * (Math.PI / 180);
			addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);
		}
		
		private function addedToStage(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
			
			addChild(missle);
			
			addEventListener(Event.ENTER_FRAME, move, false, 0, true);
		}
		
		private function move(e:Event):void {
			x -= Math.cos(radians) * speed;
			y -= Math.sin(radians) * speed;
		}
	}
}

Thanks for the help guys!

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / Bullet not shooting at target(player ship)?

This is how the Enemy Ship rotates:

private function enterFrame(e:Event):void {
	megaBossDrone.rotation = angle(ship.x, ship.y, megaBossDrone.x, megaBossDrone.y);
	}

<pre>private function angle(x1:Number, y1:Number, x2:Number, y2:Number):Number {
			var dx:Number = x2 - x1;
			var dy:Number = y2 - y1;
			var a:Number = Math.atan2(dy, dx);
			a = a / (Math.PI / 180);
			if (a < 0) {
				a += 360;
			}
			return(a);
		}

I’ll try what Bob says once I get back home unless you know why it’s not doing anything right.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / Bullet not shooting at target(player ship)?

Hi, I can’t seem to fix this problem with my game. Senekis93 helped me with part of it, but the bullet doesn’t seem to be going to where the player’s ship is.

package {
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.events.Event;
	import flash.geom.Point;
	
	/**
	 * ...
	 * @author zero579911
	 */
	public class MegaBossDroneBullet extends MovieClip {
		//DISPLAY
		private var 
		missle:MovieClip = new MegaBossDroneBulletMC,
		
		//PROPERTIES
		rad:Number = 0,
		tar:Point,
		speed:Number = 10;
		
		public function MegaBossDroneBullet(target:DisplayObject) {
			tar = new Point(target.x, target.y);
			addEventListener(Event.ADDED_TO_STAGE, addedToStage, false, 0, true);
		}
		
		private function addedToStage(e:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, addedToStage);
			
			addChild(missle);
			rad = radians(x, y, tar.x, tar.y);
			
			addEventListener(Event.ENTER_FRAME, move, false, 0, true);
		}
		
		private function move(e:Event):void {
			x += Math.cos(rad) * speed;
			y += Math.sin(rad) * speed;
		}
		
		private function radians(x1:Number, y1:Number, x2:Number, y2:Number):Number {
			var dx:Number = x2 - x1;
			var dy:Number = y2 - y1;
			var a:Number = Math.atan2(dy, dx);
			return(a);
		}
	}
}

^ That’s my code and this is Senekis93’s code

package{
	import flash.events.Event;
	import flash.display.Sprite;
	import flash.geom.Point;
	
	public class Bullet extends Sprite{
		private var
		rad:Number=0,
		speed:int=10;
		
		public function Bullet(target:Point):void{
			addEventListener(Event.ADDED_TO_STAGE,go);
			}
			
			private function go(e:Event):void{
				rad=radians(x,y,target.x,target.y);
				addEventListener(Event.ENTER_FRAME,eF);
				removeEventListener(Event.ADDED_TO_STAGE,go);
				} 
				
				private function eF(e:Event):void{
					x+=Math.cos(rad)*speed;y+=Math.sin(rad)*speed;
					}
					
				private function radians(x1:Number,y1:Number,x2:Number,y2:Number):Number{
					var dx:Number=x2-x1;
					var dy:Number=y2-y1;
					var a:Number=Math.atan2(dy,dx);
					return(a);
					}	
					
		}
}

The enemy ship for the bullet rotates fine (a full 360 turn) but the bullet doesn’t. It doesn’t seem to shoot where the enemy ship is facing (facing the player ship).

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / Rules to Debugging

Originally posted by NineFiveThree:
Originally posted by gamebuilder15:

Once I was stuck on something for an hour. And then I discovered I spelled a variable name wrong. :P

Not sure how many times I said this before:
Get yourself a proper coding IDE and this will never happen again.

Like FlashDevelop? :D

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / First uploaded game,...

Originally posted by DannyDaNinja:

Just relax and read your comments, watch the play count rise, and in about 5 days check your revenue report and see how much cash you made!

Lol my game only lasted for like 2 days and no more cash earnings. It’s staying at $0.54.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / First uploaded game,...

Holy… Thats a pretty good game :(
My first game isn’t close to THAT good. :\

Here’s my first game xD
http://www.kongregate.com/games/zero579911/avoidinator

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Okay thanks DP.

Btw Tonypa’s tutorial is really confusing. I’ll try doing it on my own for a bit..

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Okay, I guess i’ll start on the TonyPa’s tutorial.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Yes, I am solely using FlashDevelop. No Flash CSX or anything. Just FlashDevelop and coding in ActionScript 3 using the latest Flex SDK.

And okay, thanks. I’ll try it out but also, you haven’t answered my other question: “Do you know any tutorials that involves Tile Based?” This made me ask that because 1. You said this “I have never tried that tutorial, however Tony Pa’s tutorials/engines are generally very good”.

So do you know any?

Thanks.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Originally posted by DPbrad:
Originally posted by zero579911:

Hey, I’m getting an error on the tutorial… but after a few minutes of searching on google. I found this:

http://tbg.tonypa.pri.ee/start.html

Is this a good AS3 Tile Based Game Tutorial?

I have never tried that tutorial, however Tony Pa’s tutorials/engines are generally very good.

Well do you know any tutorials that involves Tile Based? Reason why I’m asking is because I want to see every Tile Based Game tutorial, then pick the one I like best.

EDIT: It also seems I need the Flash CSX thing because he said something about this:

Here is the code in main game fla:

import TBG02;
var mygame:TBG02 = new TBG02;

Here’s the link for where this statement shows: http://tbg.tonypa.pri.ee/tut02.html

I’m kind of thinking I shouldn’t even do this tutorial with FD..

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Hey, I’m getting an error on the tutorial… but after a few minutes of searching on google. I found this:

http://tbg.tonypa.pri.ee/start.html

Is this a good AS3 Tile Based Game Tutorial?

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Originally posted by DannyDaNinja:

How do i make tile games!!?

I smell troll…. and Danny, I thought you are already onto making 2 or 1 game right now. Something with zombies… or something like that.

@BadEgg: I’ll go try the tutorial out now. Oh and you exactly get what I was trying to say.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Okay thanks, I’ll look into it and the reason why i’m against external AS3 framework is that I feel like I’m not learning anything. It feels like your just “stealing” (not really stealing, just feels;… its kind of hard to explain since your not me.) code and using its functions and not really learning how to make it yourself and all. If you get what I mean, then great! If you don’t… then I don’t have any other way of putting it.

By the way, if anyone has anymore of these I should check out, then please show me! (Doesn’t have to be good, but not bad either. So something that will help me learn/make my way to making a tile based game.)

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / AS3 Tile Based Game Tutorial?

Hi, I’ve been wondering, if there are any good AS3 tile based game tutorials?

I don’t want to use anything like flixel. I want to make Tile Based Games from scratch. (Meaning no flixel or any other AS3 Framework.)

Thanks. (Recommend me a good tile based game tutorial, thanks.)

NOTE: I don’t know if this affects anything but I’m using FlashDevelop and AS3. (I could easily translate Flash CSX code to FD though.

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / Making Games With FlashDevelop

As BadEgg suggested, try this one: http://gamedev.michaeljameswilliams.com/2008/09/17/avoider-game-tutorial-1/

Pretty much all you need to do is embed the images instead of creating symbols and other stuff. Ask us on Kongregate for help.

Look at my game, it’s made by the tutorial, just changed quite a bit of stuff since I don’t like the features MJW hands out.

http://www.kongregate.com/games/zero579911/avoidinator

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / How Long does it take to get Approved

Lol, he must’ve posted a Game Maker Game xD. (Or something close to that).

 
avatar for zero579911 zero579911 411 posts
Flag Post

Topic: Game Programming / GiTD [#3] Voting

1. DannyDaNinja (For epic seizureness and an awesome game :D)
2. ST3ALTH15

(I would’ve did 1 as Stealth and 2nd as Flex but i just love how Danny’s game could give seizures and how much it’s not really a game :D. No offense. I love it, so don’t worry Danny.)