Shake_N_Baker
53 posts
|
Topic: Game Design /
Flash games with good stories
I have to agree that most flash games don’t tend to focus on story or have very good ones if they have one at all. However there are a few out there, the most recent one I played was probably no one has to die which in my opinion had a very interesting story and style of telling it. The gameplay of many of the flash games which I consider to have reasonable quality story tends to be rather simplistic however, but given a good enough story I guess I really don’t mind.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Adjacent Grids [AS3]
A break statement should only be breaking the inner most loop, for instance:
for (var i:int = 0; i < 3; i++) {
for (var j:int = 0; j < 3; j++) {
trace(i,j);
if (i == 1 && j == 1) break;
}
}
will print:
0 0
0 1
0 2
1 0
1 1 <— breaks only inner loop
2 0
2 1
2 2
If you post the code in pastebin or something similar then perhaps one of us can help you.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
arrays
Try using null instead of undefined
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
GiTD [#28] Voting - Winners Announced!
Ah ha! Someone did notice xD. Couldn’t think of a good name that fit and left it, sorry about that. Anyways here is my vote.
1st: Explode or Die by Gamma11 – I really enjoyed the game which looked good and was intuitive. Some of the level were even rather challenging but I managed to beat them all. Great job!
2nd: Portal or Die by MossyStump – Maybe I just really like portal puzzles but I felt like this game was also really well executed and had some simplistic charm to it. With a bit more content and some polish i’m sure this will be a fantastic game.
Oh and thank you UG emily and tricky for hosting / sponsering this, it was a lot of fun.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
GiTD [#28] Entries and Discussion
Well sadly I didn’t finish =(. But it was very fun to make what I have so far, so here it is:
(unfinished) Save Kitty or Die Trying
Move: WASE / Arrows
Action: Z X , . SPACE or ENTER
I was only able to get a slime enemy that currently just sits in his spot bobbing up and down. I had planned to have a few more enemies and a little boss type enemy but wasted too much ran out of time. Regardless it was fun and I’m glad I tried this, even if I didn’t finish. I plan to finish this game soon and probably upload it here on kong. Anyways good luck to the rest of the participants!
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Best places to learn AS3?
I used this one when I was starting out, its pretty good imo. MJW Avoider
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
GiTD [#28] Entries and Discussion
Well I don’t know if I can finish in time but here is what i’ve got so far.
Save Kitty or Die Trying
Pretty much just able to move around the map and swing a worthless sword at this point. Some temporary graphics thrown in there too. I had a lot of fun making a tile editor save and load from xml for the game though, which is something i’d always wanted to try.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Image display origin point
From the docs which bob linked
var skewMatrix:Matrix = new Matrix();
skewMatrix.c = 0.25;
var tempMatrix:Matrix = this.transform.matrix;
tempMatrix.concat(skewMatrix);
this.transform.matrix = tempMatrix;
You have to set texture.transform.matrix to a matrix that has been translated (100, 100), you can’t modify it directly.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Text, Strokes, Glows, and Lag
You could always try blitting the text. Just save the textfield image of each number 0-9 and the comma to be used in a bitmapdata array, then when you need to create text on the bitmap just copypixels the numbers and commas in the right order into a new bitmapdata to be drawn on the bitmap on the stage.
Here is a little demo of how it could look/preform and here is the source
I tinted the canvas bitmap on the stage, just click to make rising textfields with glowfilters that fade out or the bitmapdata equivalents if the bitmap is on. Also put an autoclick for massive amounts of texts.
Hopefully it helps or gives some ideas, was fun to make regardless
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Program like TexturePacker
I use spritesheetpacker It exports the width/height/x/y as a text file which is easy to parse and its free. Not sure how it compares for reducing white space though.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
How would you do this?
I figure’d I’d take a shot at it, here is what I made (starts off with a black screen) move with WASD.
http://www.fastswf.com/eg4vgeY
It creates tiles of random color after the first 9 and stores them in a dictionary. And here is the code:
http://pastebin.com/SzwHwC1W
E: I should also probably mention that some of the code is rather lazily written, such as render not checking if a tile is close enough to be seen and instead just rendering anyways.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
A Simple Shooter
Either change the parameters taken in the SmallImplosion constructor or pass the values to it after construction. Something like
var imp:SmallImplosion = new SmallImplosion();
stageRef.addChild(imp);
imp.x = x;
imp.y = y;
imp.stageRef = stageRef
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
AS3 flashCS vector<bitmapData>
Remove the new in front of the Vector
private var DATA:Vector.<BitmapData> = Vector.<BitmapData>([pic.bitmapData]);
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Slowing down the preloader?
In the flash player when testing you should be able to go to View → Download Settings to choose what speed you want to simulate. Then View → Simulate Download should play the preloader as it would be seen by someone downloading at that speed.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Finding the centre of gravity of a 2D object
Woops! You’re right. The center of a right triangle for instance would most definitely not be at the center of its bounding box, so scratch what I said about that. I think you could find the center of a convex shape by averaging the X/Y coordinates of each vertex though. And after that I think the concave shapes should still be the average of the convex centers.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Finding the centre of gravity of a 2D object
Concave shapes can be represented by multiple convex shapes put together. You could find the center of the convex shapes relatively easily using bounding boxes as Mond said. With the centers of the convex shapes you could then get the average of them (you could even add weights to certain convex shapes center of mass) and this should more or less be the center of the complex concave shape. A hammer could be seen as a rectangle handle and a square head put together, both of which have easy to calculate centers of mass. The hammer head could perhaps have twice the weight of the handle so when averaging the center of mass would lean more towards the center of the hammer head than the center of the handle.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Moving very slowly [AS3]
You could just reduce the size of each step and step more often, x/y values can be moved by as small as 0.05 in flash iirc.
private function MoveMoon(e:Event):void
{
if (!(++frameCounter % 25))
{
fullMoon.x += 0.05;
fullMoon.y -= 0.05;
}
}
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Error in AS
Your if statements are wrong. A single equal sign means assign or set, so if(movedirection = 1) simply sets the movedirection to 1 and continues on as if it were if(true) written there. You want to use two equal signs to compare the value of movedirection and 1 so if(movedirection == 1) would be correct
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Scrolling Issue.
First off i’ve gotta say that those dimensions are a little strange for the screen size in my opinion. I went ahead a created a small example of how you would scroll the background to the edges of its image and stop but allow the ball to continue onwards. Here is the document class I made.
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.geom.Point;
public class Main extends Sprite
{
// constants
private const SCREEN_WIDTH:int = 1280;
private const SCREEN_HEIGHT:int = 720;
private const BACKGROUND_WIDTH:int = 1600;
private const BACKGROUND_HEIGHT:int = 2300;
private const BALL_WIDTH:int = 8;
private const BALL_HEIGHT:int = 8;
private var canvas:Bitmap;
private var canvasBD:BitmapData;
// if using flashbuilder / flashdevelop etc.
// [Embed( source = "BackgroundImage.png" )]
// private const BackgroundImage:Class;
// [Embed( source = "CenterImage.png" )]
// private const CenterImage:Class;
private var fieldImage:BitmapData;
private var ballImage:BitmapData;
// ball properties
private var ballX:int;
private var ballY:int;
private var ballSpd:int;
private var ballOffsetX:int;
private var ballOffsetY:int;
private var fieldOffsetX:int;
private var fieldOffsetY:int;
// boolean flags [0] = up, [1] = left, [2] = down, [3] = right
private var keyboardDown:Vector.<Boolean>;
public function Main()
{
if(stage)
{
init();
}
else
{
addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private function init(event:Event = null):void
{
removeEventListener(Event.ADDED_TO_STAGE, init);
// entry point
canvasBD = new BitmapData(SCREEN_WIDTH, SCREEN_HEIGHT);
canvas = new Bitmap(canvasBD);
addChild(canvas);
fieldImage = new BackgroundImage();
ballImage = new CenterImage();
ballX = BALL_WIDTH / 2;
ballY = BALL_HEIGHT / 2;
ballSpd = 15;
keyboardDown = new Vector.<Boolean>();
keyboardDown.length = 4;
keyboardDown.fixed = true;
for(var i:int = 0; i < keyboardDown.length; i++)
{
keyboardDown[i] = false;
}
stage.addEventListener(KeyboardEvent.KEY_DOWN, keyDownHandler);
stage.addEventListener(KeyboardEvent.KEY_UP, keyUpHandler);
addEventListener(Event.ENTER_FRAME, cycle);
}
private function cycle(event:Event):void
{
moveBall();
setOffsets();
render();
}
private function keyUpHandler(keyboardEvent:KeyboardEvent):void
{
switch(keyboardEvent.keyCode)
{
case 38: // up arrow
case 87: // w
keyboardDown[0] = false;
break;
case 37: // left arrow
case 65: // a
keyboardDown[1] = false;
break;
case 40: // down arrow
case 83: // s
keyboardDown[2] = false;
break;
case 39: // right arrow
case 68: // d
keyboardDown[3] = false;
break;
default:
trace("keyCode Up:", keyboardEvent.keyCode);
break;
}
}
private function keyDownHandler(keyboardEvent:KeyboardEvent):void
{
switch(keyboardEvent.keyCode)
{
case 38: // up arrow
case 87: // w
keyboardDown[0] = true;
break;
case 37: // left arrow
case 65: // a
keyboardDown[1] = true;
break;
case 40: // down arrow
case 83: // s
keyboardDown[2] = true;
break;
case 39: // right arrow
case 68: // d
keyboardDown[3] = true;
break;
default:
trace("keyCode Down:", keyboardEvent.keyCode);
break;
}
}
private function moveBall():void
{
if(keyboardDown[0])
{
ballY -= ballSpd;
if(ballY < (BALL_HEIGHT / 2))
{
ballY = BALL_HEIGHT / 2;
}
}
if(keyboardDown[1])
{
ballX -= ballSpd;
if(ballX < (BALL_WIDTH / 2))
{
ballX = BALL_WIDTH / 2;
}
}
if(keyboardDown[2])
{
ballY += ballSpd;
if(ballY + (BALL_HEIGHT / 2) > BACKGROUND_HEIGHT)
{
ballY = BACKGROUND_HEIGHT - (BALL_HEIGHT / 2);
}
}
if(keyboardDown[3])
{
ballX += ballSpd;
if(ballX + (BALL_WIDTH / 2) > BACKGROUND_WIDTH)
{
ballX = BACKGROUND_WIDTH - (BALL_WIDTH / 2);
}
}
}
private function setOffsets():void
{
fieldOffsetX = 0;
fieldOffsetY = 0;
ballOffsetX = ballX;
ballOffsetY = ballY;
if(ballX < BACKGROUND_WIDTH - (SCREEN_WIDTH / 2))
{
if(ballX > SCREEN_WIDTH / 2)
{
ballOffsetX = (SCREEN_WIDTH / 2);
fieldOffsetX = -(ballX - (SCREEN_WIDTH / 2));
}
}
else
{
ballOffsetX = SCREEN_WIDTH - (BACKGROUND_WIDTH - ballX);
fieldOffsetX = -(BACKGROUND_WIDTH - SCREEN_WIDTH);
}
if(ballY < BACKGROUND_HEIGHT - (SCREEN_HEIGHT / 2))
{
if(ballY > SCREEN_HEIGHT / 2)
{
ballOffsetY = (SCREEN_HEIGHT / 2);
fieldOffsetY = -(ballY - (SCREEN_HEIGHT / 2));
}
}
else
{
ballOffsetY = SCREEN_HEIGHT - (BACKGROUND_HEIGHT - ballY);
fieldOffsetY = -(BACKGROUND_HEIGHT - SCREEN_HEIGHT);
}
ballOffsetX -= (BALL_WIDTH / 2);
ballOffsetY -= (BALL_HEIGHT / 2);
}
private function render():void
{
// clear
canvasBD.fillRect(canvasBD.rect, 0x000000);
canvasBD.copyPixels(fieldImage, fieldImage.rect, new Point(fieldOffsetX, fieldOffsetY));
canvasBD.copyPixels(ballImage, ballImage.rect, new Point(ballOffsetX, ballOffsetY));
}
}
}
The WASD/arrow keys move in this example and the images are just png images imported to the library (although I commented some lines for the alternative with the free flashdevelop IDE) and linked for actionscript with classes consisting of
package {
import flash.display.BitmapData;
public class BackgroundImage extends BitmapData {
public function BackgroundImage() {
// constructor code
super(1,1);
}
}
}
I’m not sure what IDE you are using, I made this with flash cs5.5 but it should work with the free IDEs out there (flashdevelop etc.) as well. I also used bitmaps for the images but the same concept should apply if you’re using movieclips or sprites.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
First Game, First Preloader
I think perhaps you are adding things to the stage before the game has loaded, could be wrong. As for export to frame 2 versus the asset holder they are more or less the same. I made a simple little preloader with 2 frames and a large image exported to frame 2 but would also work if you place the image directly on frame 2 and skip to frame 3 when you start the game. Anyways this works for me, here is all the code that was involved (no timeline code or any of that)
public function DocumentClass()
{
if (stage) {
init();
} else {
addEventListener(Event.ADDED_TO_STAGE, init);
}
}
private function init(e:Event = null):void
{
this.stop();
removeEventListener(Event.ADDED_TO_STAGE, init);
loaderInfo.addEventListener(ProgressEvent.PROGRESS,preloadProgress);
loaderInfo.addEventListener(Event.COMPLETE,preloadComplete);
}
private function preloadProgress(e:ProgressEvent):void
{
trace(e.bytesLoaded + "/" + e.bytesTotal);
}
private function preloadComplete(e:Event):void
{
loaderInfo.removeEventListener(Event.COMPLETE,preloadComplete);
loaderInfo.removeEventListener(ProgressEvent.PROGRESS,preloadProgress);
this.gotoAndStop(2);//or 3 if doing assetHolder on frame 2 to skip over
// entry point
}
I think all you’d need to do would be to move the code you have in your document class constructor to the entry point comment.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Help with variables
I’d advise you to try and code in classes when possible rather than on the timeline as it is much less messy and much easier to maintain with larger code. As for why the variable is reset its because it is reinitialized when re-entering the frame. All the code you placed on the timeline frame is re-run when you enter that frame again, such as stop() when placed on the first frame of a multi-frame animation will be called each time it reaches the first frame again and so it goes for initializing variables as well.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
How can I program this?
I figured it might be worth mentioning that DisplayObjects have a z property along with x and y. You can also do a basic z sort to ensure objects closest to the screen appear in front of those further away (behind)
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
Java Games
Just browsing a few pages of the multiplayer section I found a few java games:
Spiral Knights
Steel Legions
Immortal Empire
Hopefully thats helpful.
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
[AS3] String.split() [SOLVED]
Heres an example
var str:String = "Ab12Cd34Ef56";
var reg:RegExp = /[0-9]/;
var arr:Array;
arr = str.split(reg);
trace(arr);//Outputs Ab,,Cd,,Ef,,
|
|
|
Shake_N_Baker
53 posts
|
Topic: Game Programming /
So, when looping through and checking to see if objects exist, suddenly: ERROR
Doesn’t this[“name”] throw the error when “name” doesn’t exist? Maybe I’m missing something but can you use this.getChildByName(“name”) != null instead?
|