Sparkky
20 posts
|
Topic: Game Programming /
[SOLVED] Turret AS2
Math.sin()
Math.cos()
Math.tan()
Math.asin()
Math.acos()
Math.atan()
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
[AS3] - Properties of a MC within a MC
I’ve never had to do that, but Im not familiar with how flash deals with code in the timeline… Its probably something do with that that though.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Flash Developing Software
I use flash CS4, but do most of my coding in “Flash Develop” because its got much more context features and just overall more features im used to having as a coder.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
'Push' function for multidimensional arrays
the way flash handles 3d arrays in an array of arrays.
What do you consider the end of the 3d array because your probably going to need to create your own code to handle it.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Collision Logic
personally, Id look into a presetup physics engine like box2d which does all the fancy math for this for you.
If you want to create your own and prevent tunneling a popular technique is to check the old position and the final position.
Then you keep checking in between (generally halving) until you run our of time, then return the result at that point.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
[AS3] Calling functions of children
Id use the array.
You could always use a
“for each()” loop and make it look really pretty :P
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
TD games
Doesn’t really make sense, you might be able to, but you’d probably need a lot of AS code to make it work… if for example you were talking to make a snake type mob for a TD, there is probably better ways to go about this just using AS3
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Accessing a variable declared in TL
oh okay
package {
import flash.display.MovieClip;
import flash.display.*;
public class hero extends MovieClip {
public function hero() {
creation();
}
public function creation() {
this.x=50;
this.y=50;
}
}
}
what your missing is that your didnt declare a constructor which must be a public function with the same name as the class.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Remove itself once the mc hits certain frame (AS3)
try this and see if it works
fadeOut.parent.removeChild(fadeOut);
Also, where is this code contained. Is it in a seperate as file, or is it in the first frame of the timeline?
If you wan’t to look at a more OO approach to this problem a little more background would be helpful on whats happening in this situation.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
as3 and C++
well if you were just learning the basics of C++, probably not much.
If you’ve learnt about the OOP paradigm, then that will transfer over.
The ideas of encapsulation and modular design are both ideas you can pull across as3 <→ c++
Pointers and deconstructers are 98% irrelivant in as3.
As for other “styles” of languages, I’ve written in both scheme and prologue, and “nifty” factor aside the only thing I walked away with from them is a impractically good understanding of recursive statements.
I don’t think it was a total waste of my time, but its nothing that I couldn’t have learnt while also learning on a more practical language.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Removing movieclip:broken from an array.
Well that really depends on which route you want to take.
If your more interested in AI for example, Your best (almost only these days) bet is to go for a masters degree in computer science focusing on AI.
If you want to be a coder, Computer science isn’t the best route, but its not bad as long as you keep your coding skills up. But your also going to come out with knowledge about code design you wouldn’t learn in a 2 year program like CIS.
Your degree really doesnt mean much in the video games industry sadly. Salary information shows a minimal correlation between education and pay, and companies will tell you repeatedly they care more about experience than than degrees.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Removing movieclip:broken from an array.
yea my university doesnt offer a videogames related program, so Im just finishing up my 4th year of computer science.
We did have an visiting prof come in and teach a fourth year video game development course.
Was lotsa fun, he flew in the VP of EA to come talk with us, met the AI consultant for Bioware (also the man who created the perfect checkers playing bot).
We looked at some of the AI work done in games, and some of the development, really eye opening to the whole process, especially looking at it from a very academic perspective (traditional computer science background).
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Removing movieclip:broken from an array.
Using a circle array… sounds like a C programmer lol :D
One thing to make sure is because AS2 uses a stage, even if you override the bullet on the array, the object will still be referenced on the stage and taking up memory.
You will still need to create a deconstructor for the bullet you are replacing on the array.
If your not already removing the bullets from the stage when you remove them from the array, you may want to try it and see if that improves performance.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Mouse Follow Code
oh sorry, I’m working in AS3… maybe you should be too wink wink, nudge nudge
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Removing movieclip:broken from an array.
I would create a Bullet class and have a static array of all the bullets in play for example activeBullets:Array
then I would declare an isAlive() function for the bullet class. This would allow you to tell if a bullet is outside of the game stage and is safe to delete.
In sudo-code
if(this.x > gameMaxX || this.x < gameMinX || this.y > gameMaxY || this.y < gameMinY)
return false;
return true;
Then what you can do is iterate through the array and anytime bullet.isAlive() is false, just splice the bullet out;
for(i:int = 0 ; i < Bullet.activeBullets.length ; i++)
if(!Bullet.activeBullets[i].isAlive())
Bullet.activeBullets.splice(i,0);
ofcourse you’d have to work in your drawing/deleting code as well and such, but I think structuring it like this would help.
There is so little going on in your game I’m very confident in saying that it is likely something not properly getting removed rather than a slow splicing.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Mouse Follow Code
why not tack it on a mouse move event, then just get the x,y from the event?
onMouseMove(e:MouseEvent)
{
var delY:Number = e.stageY – object.y ;
var delX:Number = e.stageX – object.x;
object.rotation = Math.atan2(delY, delX));
}
this way it only triggers when you actually move the mouse.
You may need to alter the rotation by a constant, But I think atan2 gives the right answer in this case.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Amazing as3 tutorial:
Emanuele’s blog is probably for people who are a bit more comfortable with coding.
Personally I get bucket loads out of it, but there isn’t too much hand holding or basic tutorials.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Push isnt working?
to make them respawn, I would structure the spawning code differently.
Think of the enemies array as an array of enemies waiting to spawn.
public function spawn()
{
if(enemies)
addChild(enemies.shift());
}
this would check if there was an enemy sitting in the enemies array, and if there was shift out the first one and add it to the stage.
To start respawning you need to create a function that when a mob dies, it is pushed onto the enemies array
private function killed()
{
parent.removeChild(this);
enemies.push(this);
}
now every time the respawn function is called, any mobs that are dead are put back into the world FIFO (first in first out).
You can control the respawn speed by creating a timer event that would call the spawn() function at the set time.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Variables, what is it???
I would get into the habit of casting.
Helps find bugs later, and other than Python and AS3, most languages are strongly typed, which makes casting mandatory.
|
|
|
Sparkky
20 posts
|
Topic: Game Programming /
Programming Forum Games [Set t = 10]
sadly not watkins, thats something you only get to pull in C :P
how about…
…oops didnt math up properly, fixing
|