Recent posts by BartAS3 on Kongregate

Flag Post

Topic: Game Programming / arrays

Is there anyway in actionscript 3 to check if an Array exists?

I tried..

var myArray:Array

if(myArray != undefined){

do this

}else{

do that
}

but is doesn’t seem to work..

ideas…anyone???

 
Flag Post

Topic: Game Programming / floodfill algorithm

Problem is solved.
It was a floodfill on tile movieclips.

 
Flag Post

Topic: Game Programming / floodfill algorithm

Hello,

Anyone who can help me solve a problem in a actionscript 3.0 experiment that uses this algorithm?

If you do then i will submit my code and experiment here.

 
Flag Post

Topic: Game Programming / Tilebreaker

My problem for creating a tile breaking game is to move tiles with a smooth animation.

Check for each tile if it can move down and its within the array.

private function canMove(r:int,c:int)
		{
			if (GameField[r] == null)
			{
				return -1
			}
			if (GameField[r][c] == null)
			{
				return -1;
			}
			
			if (GameField[r+1][c] == 0)
			{
				return GameField[r][c];
			}

		}

This function updates positions in array en move tiles in correct place.

private function checkRemainingTiles(event:Event)
		{
				for(var a:int = 0 ; a<GameField.length - 1; a++){
					for(var b:int = 0 ; b<COLUM ; b++){
						
						var ct_tile = container.getChildByName(a + "_" + b)
						
						if(canMove(a,b))
						{
							
							GameField[a+1][b] = GameField[a][b]
							GameField[a][b] = 0
							container.getChildByName(a + "_" + b).name = (a+1) + "_" + b
							ct_tile.y += OFFSET
							CheckGameFieldStatus(GameField)
						}
						
					}
				}
		}
		

This function allows me to see my entire GameField status.


private function CheckGameFieldStatus(array:Array)
		{
			
			trace("")
			trace("")
			for( var i:int = 0 ; i<array.length ; i++){
				trace(array[i])
			}
			
		}

The problem is when i use tweenlite instead of “ct_tile.y += OFFSET” of the CheckRemainingTiles function those tiles don’t move in the correct position " ct_tile.y += OFFSET works correctly and move the tile in their proper position. Why does tweenlite give errors? I don’t get it. The CheckRemainingTiles function works with an enterframe event.

 
Flag Post

Topic: Game Programming / classes and private/public functions

Hello,

i have build a class for a countdown…

package
{

import flash.utils.Timer;
import flash.events.TimerEvent;

public class countdown
{
private var timer:Timer;
private var CurrentCount:int;
private var count:int

public function countdown(count:int)
{
// constructor code
timer = new Timer(1000,count);
timer.addEventListener(TimerEvent.TIMER,tick);
timer.start();
}

private function tick(event:TimerEvent)
{

CurrentCount = count – timer.currentCount;
trace(CurrentCount);
}

public function showCountDown():int
{
return CurrentCount
}

}
}

On the main timeline i created an instance of this class this way…

var mycountdown:countdown = new countdown(10)
display.text = String(mycountdown.showCountDown())

10: number of seconds to countdown
display: is a textfield on the stage that shows the countdown…( this is not happening). Probably because the showCountDown function only runs once….
It must update every timing cyclus…

The countdown runs with negative integers ( 0, -1, -2, -3, etc….)
i do not understand why…if i give the count variable in the class the value of 10 then it runs the way it should be.

Anyone who can help me out?

 
Flag Post

Topic: Game Programming / tilebased and tweenlite.

Entire project @

http://users.telenet.be/myflashgames/Tilebreaker.zip (FLA, SWF, com folder, AS )

still need to import easing class and com.greensock at the top of the actionscript 3 main class

 
Flag Post

Topic: Game Programming / tilebased and tweenlite.

I have changed the timer to 1 second delay and used the normal dropdown.

check on http://users.telenet.be/myflashgames/

SIZE is indeed the tilesize.

All tiles are falling down in the correct position.
@Draco18s…why doesn’t tweenlite do the job correctly?

can you suggest the solution?

 
Flag Post

Topic: Game Programming / tilebased and tweenlite.

my function on a timerEvent of 10 milliseconds

private function MoveTilesDown(event:TimerEvent)
{

for (var i:int=0; i<GameField.length; i++)
{

for (var j:int = 0; j<GameField[i].length; j++)
{

if ( i > 0)
{

if (GameField[i][j] == 0 && GameField[i – 1][j] > 0)
{

var currentTile = TileContainer.getChildByName((i-1) + “,” + j)
TweenLite.to(currentTile ,.2,{ease:Linear.easeOut,y:currentTile.y + SIZE})

//TileContainer.getChildByName((i-1) + “,” + j).y += SIZE;
TileContainer.getChildByName((i-1) + “,” + j).name = i + “,” + j;
GameField[i][j] = GameField[i – 1][j];
GameField[i – 1][j] = 0;
}
}

}
}

}

demo running at: http://users.telenet.be/myflashgames/

does anyone understand why my tiles arent completely moving down or dont fit in the correct position?

 
Flag Post

Topic: Game Programming / removechild on multiple objects after a tweenlite

Like this?

for(var j:int = 0 ; j < 15 ; j++)
{

var object = clipcontainer.getChildByName("object"+j)
TweenLite.to(object,1,{x:object.x + 50, alpha:2, rotation:45,delay:2, onComplete:clipcontainer.removeChild, onCompleteParams:[object]});
}

 
Flag Post

Topic: Game Programming / removechild on multiple objects after a tweenlite

hi there, I want to use tweenlite in a game. for experimenting with tweenlite i set up a test flash file.

1. displayobject with number of childobjects.
2. Some or all childobjects are performing a tween.
3. after the tween, the multiple childobjects must be removed.

My problem is when i use removechild on my childobjects, i never get to see the tween. Anyone who knows how to accomplish this?

import com.greensock.TweenLite
import fl.motion.easing.*
import flash.display.MovieClip;

var clipcontainer:MovieClip = new MovieClip()

addChild(clipcontainer)

for(var i:int = 0 ; i < 15 ; i++)
{
var myclip:clip = new clip()
clipcontainer.addChild(myclip)
myclip.x = 200
myclip.y = 15 + i * 32
myclip.name = “object” + i

}

for(var j:int = 0 ; j < 15 ; j++)
{
//clipcontainer.removeChild(clipcontainer.getChildByName("object"+j))

var object = clipcontainer.getChildByName("object"+j)
TweenLite.to(object,1,{x:object.x + 50, alpha:2, rotation:45,delay:2});
}

//how to remove my childrenobjects from clipcontainer after tweenlite???

for(var k:int = 0 ; k< 15 ;k++)
{

TweenLite.getTweensOf(clipcontainer.getChildByName("object"+k))
clipcontainer.removeChild(clipcontainer.getChildByName("object"+k))

}

 
Flag Post

Topic: Game Programming / pawn solitaire game

Problem solved.
i have chosen for a drag and drop system.
Now the player can automatically make his choice.
drag and drop with eventlisteners is easy to build in flash and AS3.0

2 functions onDrag, onUP with mouseEvent
2 eventlisteners onMouseDown and onMouseUp

one critical issue….debug invalid moves etc…..
important that when you use drag and drop……make sure that all the bugs are worked out.

 
Flag Post

Topic: Game Programming / pawn solitaire game

hey,

i’m building a tile based game pawn solitaire wich is a known board game. This time i try to build it in flash. i tought i had everything in mind for making the game. I build everything in a mouseEvent. Click on a pawn and it checks on every surrounding row and colum it can move to. Now in some situations some of the pawns can move to multiple positions and i didn’t count for that in my study to make the game leaves me with an serious bug to deal with.

Other examples i found on the internet work often with an drag and drop system but i wanted to play my version a little faster. One click for every pawn…

no dragging or whatsoever……

Can anyone help me for a good solution?

 
Flag Post

Topic: Game Programming / bricksbreaker

That works although i had to work out a few bugs….

 
Flag Post

Topic: Game Programming / Collisions...

Hello,

I have a strange collision detection problem…

A maze of balls ( rows & colums ) and a ball i firing on it.
When the speed of the fired ball is to high i get some strange display results.
the ball overlaps another ball in the maze en that is not entirely correct. They should be stacking like a bubbleshoot game.

Everything works as it should be when i use a low speed for the fired ball.

For the collision i loop the entire maze with the fired ball en when a collision is detected i use a break statement because there is no point in continuing to look for collisions…

Can anyone explain why i get odd result with higher speeds?

 
Flag Post

Topic: Game Programming / bricksbreaker

Hello,

i want to make a prototype tile based game as bricks breaker. I know how to setup some elements to setup a flash game, have experience with AS3.0 and did some reading in de book “Flash game development by example”.

What have I done?

1. Make a grid of rows and colums(12*12) of colored tiles and stored their Timeline framenumber as the color in an multidimensional array. A basic setting of a tile based flashgame.

(Frame 1: yellow tile, frame 2: red tile,….)

In Array (1,2,…)

2. Add for each tile a mouseEvent. When I click on it , the tile must be removed from the grid and the array must be updated of its value.

3. Certain areas in the grid have the same color. That area ( same color ) is removed using a floodfill.

Those 3 steps are completed and working.

Now I must find a way to drop down all the tiles above the removed area. So you can say that for each colum the tiles must shift down ? x tiles.
Also when an entire colum is removed, all the tiles on de left side of that colum must shift 1 tile to the right.

People who already played this game know what i mean…..

The only clue that I have is “backtracking algorithm”?
I am not sure if this can help me ? How does it work en how do you implement it?
It seems a simple logic problem, however it is not always that easy…..

is there a way to share my AS files here?

Can anyone help me on this one?

Thank you..