Recent posts by Mond on Kongregate

Subscribe to Recent posts by Mond on Kongregate

Nov 27, 2008
avatar for Mond Mond 63 posts

Topic: Programming / lifebar: better in front or behind?

IMO, a health bar integrated into the character looks better than a floating rectangle. EX: a bomber with bomb icons down the fuselage, as the bomber takes damage the icons disappear. EX: the characters’ armor changes color as the health decreases. It involves a bit more coding. And thought in the character design phase.

 
Nov 17, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Array of Movie Clips

Yes. Post some code using the pre tags if you’re having probs. What language are you working in?

 
Nov 17, 2008
avatar for Mond Mond 63 posts

Topic: Programming / AS3 - Untyped Function Headers

If I code this:


function AwardUpgrade(upgradeNum:uint)

I always thought it was the same as coding this:

function AwardUpgrade(upgradeNum:uint):void

However, I have read (on another site) that when the return type is left off, the compiler defaults to a return type of Object, not void. And the Object default return type causes execution-slowing overhead.

So maybe I should always type my functions rather then let the default handle it? This is a general discussion question. Anybody observed any discernible increase in performance specifying the void function return type?

 
Oct 20, 2008
avatar for Mond Mond 63 posts

Topic: Programming / localToGlobal, one level up or all the way

Yes, that’s true. For the y value of pt.

The value of pt I was expecting in the last trace was approximately (350,304), but I’m getting (0,608).

 
Oct 20, 2008
avatar for Mond Mond 63 posts

Topic: Programming / localToGlobal, one level up or all the way

depthCharges are addChilded onto the battleField which is then addChilded onto the Stage....and I was trying to
get this code to work

var pt:Point = new Point(0,0);
pt=depthCharges[i].localToGlobal(pt);
trace("In MoveAllObjects - depthCharges[i].x:",depthCharges[i].x,"depthCharges[i].y:",
depthCharges[i].y, pt:"+pt);
.
.
.
In MoveAllObjects - depthCharges[i].x:0 depthCharges[i].y:302 pt:(x=0, y=604)
0 302 304 //From a trace in my Bullet Class...trace(dcInStageCoor.x, dcInStageCoor.y, explosionDepth);
In MoveAllObjects - depthCharges[i].x:0 depthCharges[i].y:302.5 pt:(x=0, y=605)
0 302.5 304
In MoveAllObjects - depthCharges[i].x:0 depthCharges[i].y:303 pt:(x=0, y=606)
0 303 304
In MoveAllObjects - depthCharges[i].x:0 depthCharges[i].y:303.5 pt:(x=0, y=607)
0 303.5 304
In MoveAllObjects - depthCharges[i].x:0 depthCharges[i].y:304 pt:(x=0, y=608)
0 304 304
Explode 0 304 304 //another Bullet Class trace...trace("Explode",dcInStageCoor.x, dcInStageCoor.y, explosionDepth);


But I don't seem to be getting Stage coordinates from the localToGlobal call, are they battleField coordinates?
(one level up) Or does localToGlobal always return Stage coordinates (all the way), regardless of how deeply in
the display list the object is buried?


EDIT: It must be "all the way" because it works in another section of my code. But, I am passing the (0,0) point to localToGlobal, that is to say, the registration point (in local coordinates) of a depthCharge object, which is in the depthCharges Array....shouldn't localToGlobal return the Stage coordinates for the depthCharge registration point? What am I doin' wrong? Thanks for any help.
 
Oct 19, 2008
avatar for Mond Mond 63 posts

Topic: Programming / localToGlobal Coordinate Doubling

OK, I got it! Thanks Moonkey. No wonder my explosion animations are a few hundred pixels off from the detonation point. lol.

 
Oct 19, 2008
avatar for Mond Mond 63 posts

Topic: Programming / localToGlobal Coordinate Doubling

But dcBars parent is the stage, I thought….stage.addChild(dcBars);

The x and y properties of dcBar (11 and 262.5), aren’t stage level values?

 
Oct 19, 2008
avatar for Mond Mond 63 posts

Topic: Programming / localToGlobal Coordinate Doubling

Could someone help me understand why this conversion is doubling the Sprite coordinates?


var dcBars:Sprite = new Sprite();
dcBars.x = 11.0;
dcBars.y = 262.5;
dcBars.graphics.lineStyle(0,0xFFFF00,1.0,false,LineScaleMode.NONE);
dcBars.graphics.beginFill(0xFFFF00);
dcBars.graphics.drawRect(0.0, 0.0, 15.0, 3.0);
dcBars.graphics.drawRect(675.0, 0.0, 15.0, 3.0);
dcBars.graphics.endFill();
dcBars.visible = false;
stage.addChild(dcBars);

trace(“At dcBars creation – dcBars.x:”,dcBars.x,“dcBars.y:”,dcBars.y);

var pt:Point = new Point(dcBars.x, dcBars.y);
var ptStage:Point = new Point(0,0);
ptStage = dcBars.localToGlobal(pt);

trace(“At dcBars creation – pt:”,pt);
trace(“At dcBars creation – ptStage:”,ptStage);

And the trace Output:


At dcBars creation – dcBars.x:11 dcBars.y:262.5
At dcBars creation – pt:(x=11, y=262.5)
At dcBars creation – ptStage:(x=22, y=525)

EDIT: Also, why are the tags double line spacing? I didn’t copy/paste the code snippet double line spaced.

 
Oct 15, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Pixel-Copying Routine?

Thanks ya’ll.

That rotation property worked great on my DriveWheels, thanks Phant.

 
Oct 15, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Pixel-Copying Routine?

"A BitmapData object can be drawn to the screen by a Bitmap object in one of two ways: by using the vector renderer as a fill-bitmap shape, or by using a faster pixel-copying routine. The pixel-copying routine is substantially faster than the vector renderer, but the Bitmap object must meet certain conditions to use it:

No stretching, rotation, or skewing can be applied to the Bitmap object.
No color transform can be applied to the Bitmap object.
No blend mode can be applied to the Bitmap object.
No clipping can be done through mask layers or setMask() methods.
The image itself cannot be a mask.
The destination coordinates must be on a whole pixel boundary."

What is this “faster pixel-copying routine”?
Is it the copyPixels() method of the BitmapData Class?
Thanks for any help pointing me in the right direction, I have been reading for a while, looking for this faster routine.

Quote taken from Adobe Flash CS3 Professional Manual.

 
Oct 13, 2008
avatar for Mond Mond 63 posts

Topic: Programming / DriveWheel, Z-Axis Rotation

The path is parabolic in some sections, circular in others, linear in others.

I will be using the rotate method on these drive wheels, I just didn’t know the rotate method existed.

As far as the rest of what I posted (MC vs array), I was just thinking out loud. Thanks for the help.

 
Oct 13, 2008
avatar for Mond Mond 63 posts

Topic: Programming / DriveWheel, Z-Axis Rotation

OK. I found the Matrix Class and Transform Class (reminds me of OpenGL) and rotate method.

Isn’t the MovieClip and its frame numbers analogous to an array and its index? If array access is the fastest access possible, it seems reasonable that frame number access would also be the fastest access. The vector graphics data would have been pre-transformed before storing it in its frame number location. Or is it just the base vector graphics that is stored (frame 1 for instance), and each frame number location actually refers to a set of transformation matrices that are needed to represent the graphics for that frame? The transformations (Dot Products or Cross Products) still have to occur to render to the screen, therefore no time is saved by using the animation Z-axis rotation method?

 
Oct 12, 2008
avatar for Mond Mond 63 posts

Topic: Programming / DriveWheel, Z-Axis Rotation

Hi Phant. The path the weapon travels is a closed loop.

I don’t understand the “just rotate the movieclip”, don’t I have to use an animation to get Z-axis rotation on an object? I don’t know any other way of doing it.

The larger the array, the more detailed & smooth the movement.

I was thinking more in terms of one pixel of movement along the path should equate to one pixel of movement along the circumference of the drive wheel. I’m working in AS3.

 
Oct 12, 2008
avatar for Mond Mond 63 posts

Topic: Programming / DriveWheel, Z-Axis Rotation

I have an 18 pixel diameter DriveWheel in my game I want to rotate about the Z-axis when my weapon moves along a specific path. Here are some values I traced out:

Velocity:16.500034468101305
dt:33
previousAP:7784 currentAP:7791
----------------------------------
Velocity:20.100034468101306
dt:36
previousAP:7791 currentAP:7798
----------------------------------
Velocity:23.600034468101306
dt:35
previousAP:7798 currentAP:7805
----------------------------------
Velocity:27.000034468101305
dt:34
previousAP:7805 currentAP:7812
----------------------------------
Velocity:30.300034468101305
dt:33
previousAP:7812 currentAP:7819
----------------------------------
Velocity:33.600034468101306
dt:33
previousAP:7819 currentAP:7826
----------------------------------
Velocity:36.9000344681013
dt:33
previousAP:7826 currentAP:7833
----------------------------------
Velocity:40.4000344681013
dt:35
previousAP:7833 currentAP:7840
----------------------------------
Velocity:43.8000344681013
dt:34
previousAP:7840 currentAP:7847
----------------------------------
Velocity:47.1000344681013
dt:33
previousAP:7847 currentAP:7861
----------------------------------
Velocity:50.400034468101296
dt:33
previousAP:7861 currentAP:7875
----------------------------------
Velocity:53.70003446810129
dt:33
previousAP:7875 currentAP:7889
----------------------------------
Velocity:57.800034468101295
dt:41
previousAP:7889 currentAP:7903
----------------------------------
Velocity:61.20003446810129
dt:34
previousAP:7903 currentAP:7917
----------------------------------
Velocity:64.50003446810129
dt:33
previousAP:7917 currentAP:7931
----------------------------------
Velocity:67.80003446810129
dt:33
previousAP:7931 currentAP:7945
----------------------------------
Velocity:71.50003446810129
dt:37
previousAP:7945 currentAP:7966
----------------------------------
Velocity:75.00003446810129
dt:35
previousAP:7966 currentAP:7987
----------------------------------
Velocity:78.30003446810129
dt:33
previousAP:7987 currentAP:8008
----------------------------------
Velocity:81.60003446810128
dt:33
previousAP:8008 currentAP:8029
----------------------------------
Velocity:84.90003446810128
dt:33
previousAP:8029 currentAP:8050
----------------------------------
Velocity:88.20003446810128
dt:33
previousAP:8050 currentAP:8071
----------------------------------
Velocity:91.50003446810128
dt:33
previousAP:8071 currentAP:8092
----------------------------------
Velocity:94.90003446810128
dt:34
previousAP:8092 currentAP:8113
----------------------------------
Velocity:98.50003446810128
dt:36
previousAP:8113 currentAP:8141
----------------------------------
Velocity:102.20003446810128
dt:37
previousAP:8141 currentAP:8169


The AP values are Array Pointer values. The AP values control the weapon's movement. There is approximately one pixel of movement for each element in the array. That is to say, going from AP=110 to AP=111, the weapon has moved one pixel along it's parabolic path.

The weapon can accelerate to a maxVelocity, which is dependent on the level of upgrade for the weapon. At the higher velocities any detail in the DriveWheel becomes a blur. So it just has to look good in the lower velocities.

I think I have to use the velocity to determine the DriveWheel frame number to display gotoAndStop(DetermineDWFrameNumber()); I could use the AP differential, but the AP value rolls over from 11368 back to 0. So the differential isn't always consistent in a "previousAP minus currentAP" kind of way. If the velocity is negative, the DriveWheel has to reverse direction since the weapon reverses direction along it's path.

This will probably end up being a "trial and error" sort of thing, but could anyone suggest an equation/algorithm to help me get this started? Also, how many frames should the DriveWheel MC have in it? 20? 50? 360? I used 360 frames in my weapon MC and it still looks a little bit steppy to me. Thanks for any help.
 
Oct 6, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Sprites and AS

Thanks Phant. I’ll read up on those bmd objects.

 
Oct 6, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Sprites and AS

Thanks Haelix. That is my intention, to create the TT blocks and numerical font as Sprites, however, the Flash Authoring Tool, which I use to create artwork for the game, does not support the Sprite type. Only MovieClip, Button, & Graphic types. And the Graphic type cannot be exported for AS. So it seems that I must create the blocks in a TTBlocks Class using Graphics Class methods if I want them to be Sprites. And that is easy enough to accomplish.

The numerical font is a different story. To create the numerals in a NumFont Class using Graphics Class methods is beyond my limited art experience. I could just use an existing font, but I didn’t want to give up on my spectacular, perfect fitting, well designed, highly desirable, custom made numerical font! :)

 
Oct 4, 2008
avatar for Mond Mond 63 posts

Topic: Programming / 1 quick question

What language are you working in? Basically, assign an event listener to “listen” for input from the keyboard. And then code an event handler that performs the desired action based on the key pressed.

 
Oct 4, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Sprites and AS

Is it possible to export a Sprite/Graphic for AS? I am working in Flash CS3/AS3.

I have a TickerTape in my game which moves across the bottom of the stage. Each block of the TT is a MovieClip, but they don’t need to be MovieClips as there is no animation associated with these TT blocks, just some text describing the upcoming enemy. In addition, each block of the TT has a level/block number superimposed (addChild) on it. Each numeral is also a MovieClip. (I created my own 0-9 numerals) I have limited the number of instantiated TT blocks to 15 at any one time, but that is 45 MovieClips (2 numerals + the block) on the stage for an element of the game where MovieClip functionality isn’t required.

Is my only option the Graphics Class to create these blocks & numerals in AS3 code? Or can I use the Flash Authoring Tool, convert to a Graphic symbol, and still be able to reference the blocks & numerals from the document class or external .as file? Thanks for any ideas on this.

 
Sep 30, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Range of Values - Switch

Thanks Kal. Did you leave the typing off of the function header


function APToCoeff(AP:uint):Number {

or can a return and function arguments be accomplished without specifying the type? I have always coded heavily typed. I haven’t experimented with the “everything is an object” concept.

Thanks Phant. That code is abusive, and funny! I think I see some sweat dripping off the seventh question mark. And the eighth one looks downright pale! :)

 
Sep 30, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Range of Values - Switch

AP Value Coeff Value
0 – 5 any value
6 – 594 10.0
595 – 665 any value
666 – 864 9.2
865 – 898 9.4
899 – 955 9.6
956 – 1048 9.8
1049 – 1259 10.0
1260 – 1289 9.8
1290 – 1305 9.6
1306 – 1401 9.4
1402 – 1557 9.2
1558 – 1623 any value

The values for the coefficients and range limits are chosen the way they are because it makes the gun movie clip look good on the stage. The value of the coefficient can be “any value” in some places because control of the coefficient’s value in those ranges is transferred to different code.

 
Sep 29, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Range of Values - Switch

The application is this…An array pointer whose value varies between 0 and 1623. That set is broken into 11 ranges of varying sizes. When the AP value is within one of the ranges, the value of a coefficient to a trigonometric equation is set, each range corresponding to a different coefficient value. The AP can increase or decrease and wraps around from 0 to 1623 and 1623 to 0.

The iterative subtraction algorithm works ok, but it is not the most elegant code I’ve ever written. I have attempted a search for a mathematical relationship between the ranges and the coefficient values, but I haven’t found anything consistent.

The game is a simple shooter that utilizes an array (1024 X 5) for the gun’s movement. I could add the coefficient values as elements in the array, making it 1024 X 7 (there are two coefficient values to specify), but after having chosen values for the 5120 elements I already have . . . . . if I ever code another shooter, I don’t think I will use the array method. I’m working in AS3.

SideNote: How bout them Carolina Panthers!? :)

 
Sep 28, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Range of Values - Switch

Thanks Phant. I was using iterative subtraction to decide which range I was in. I was looking for ideas that might execute faster since this code resides in an enter frame handler. (faster than subtraction???? :)

So there is no way around that darn Switch statement accepting only a single argument….I am beginning to understand what you mean in your posts concerning the limitations of AS.

 
Sep 27, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Range of Values - Switch

I am looking for a way to execute specific code depending on a range of values. This doesn’t work since a Switch-Case does not support ranges:


switch(DayofMonth)
{
case 1-7:trace(“First Week”);break;
case 8-14:trace(“Second Week”);break;
case 15-22:trace(“Third Week”);break;
case 23-30:trace(“Fourth Week”);break;
default:trace(“out of range”);break;
}

However, this does work:


switch(DayofMonth)
{
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:trace(“First Week”);break;

case 8:
case 9:
case 10:
case 11:
case 12:
case 13:
case 14:trace(“Second Week”);break;

.
.
etc.
.
.
default:trace(“out of range”);break;
}

That is impractical for me since my values are from 0 to 1623, split up into 11 different ranges. Anybody know of a better way to accomplish this (other than 11 If statements)?

 
Sep 2, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Buying Flash-Help!

I paid $315.00 USD for Adobe Flash CS3 Professional in April 2008. There is an “educational” version that should be less expensive.

 
Aug 2, 2008
avatar for Mond Mond 63 posts

Topic: Programming / Creating .as files and packages...

Yes it is (it was done this way in the book I bought to learn AS3). You answered your own questions with every question you asked:...of the class defined by your symbol?....so you can actually get the Submarine class…..access a class that’s defined by a symbol in the library…..

It is because when I did the linkage on the symbol in the library, I created a Class. Now anything I can do with a Class is available to me. The Class already has Movie Clip behaviour/properties, now I will extends the Class I created (actually inheriting from the Base Class) with additional behaviours/properties the instances of this new Class require to function in my game.

Assets in the .fla Library, exported for AS, are resources for the .as files (as long as the target name is correct on your .as file) I think of them as Global Classes. Which is why I didn’t need to import anything.

You may be correct about it seeming backwards..When I bought Flash, I knew I was weak in Art, form, color….texturing.. so I started in the Flash Authoring Tool learning graphics. Phant reminded me I was going at it backwards..A good idea is to use placeHolder graphics until the coding is done (nearly done). Get the functionality down, then plant some flowers.

EDIT: As a “worthy newbie”, I was trying to understand all of Flash’s functionality. The more I understood, the better code I could produce. But Flash is a fairly large mountain of info to digest, with a challenging learning curve. I found a way/understanding that works for me. To wait until I understood everything before I could produce anything was going to take quite a while.