Recent posts by NineFiveThree on Kongregate

Flag Post

Topic: Game Programming / questions about moving objects with delta time.

Originally posted by FlashGrenade:

how would you calculate time based movement?

With the velocity of the object and the time.

Originally posted by FlashGrenade:

If objects controlled by the player and the cpu are superclasses of an animated object, how would movement be regulated?

One class can only have one superclass in As3.

Assuming you mean “subclass”:
Like any other code that can be abstracted (generalized) for all subclasses, the movement code could go into the superclass.

 
Flag Post

Topic: Game Programming / Overhead daynight system

Originally posted by PanisRahl:

True, but would it be better to have to create a new object every time i need to run that function, wouldn’t it be easier to call a line function then the 3 (7 in this case) lines it takes too create an object?

I have no idea what you are trying to say here, could you please try to explain that again?

Originally posted by PanisRahl:

Also the mask is 1 smaller object (obj.mask/campfire.mask) masking another larger object (night.mask)

Your game seems to be tile based.
Now you are trying to apply some global night visual.

I don’t think these two concepts mix well. I’d stick with the tile based idea and simply create sprites for the night.

 
Flag Post

Topic: Game Programming / Overhead daynight system

Originally posted by PanisRahl:

lol i can move the mask anywhere and it still doesnt work

Does “the mask” mean that you are trying to use the same mask for every displayobject?
In this case, did you rtfm?
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayObject.html#mask


A single mask object cannot be used to mask more than one calling display object.

Originally posted by PanisRahl:

has nothign tod o with my obj:Movieclip

No it doesn’t, but I still gave you that advice, because your code makes not too much sense the way it is.
You asked for “a better way of doing it”.

 
Flag Post

Topic: Game Programming / Overhead daynight system

Why do you pass a MovieClip reference as the first parameter to your function if the first thing you are doing in said function is to set this reference to some other newly created object?
I would not recommend to hard code any specifics like “this should only happens if it’s a campfire” in a general purpose function that adds objects to a world.

 
Flag Post

Topic: Game Programming / In-game Events: Storing the target as a variable or passing it each time

variables are just references to objects.

I guess you should elaborate on your problem further.
You merely mention that there are “GameEvents” and from the rest of the post they have some relation to a target.

If you actually explained what they are, helping you would be a lot easier.
So what is a GameEvent?
Give a concrete example of how such an object is used.

 
Flag Post

Topic: Game Programming / This piece of code causes memory leak. Unsure, why.[as3]

Originally posted by a3lex33:

Why is it a bad habit? It is rather useful to have Global and Data classes, defined like this, to keep most important/most used functions and data in special place.

Stuffing everything into one file becomes very messy very quickly.
After all, that’s one reason why object oriented programming was invented.
Concerns can be nicely split up.

You have one bulk of code that cannot be tested separately. This also makes sharing it harder.
You didn’t even show us all the code “//some code, in which t is defined”.
Code cannot be reused, because everything is depending on Global.

There’s a reason why strategies like MVC are the standard when it comes to building applications.
This is a good example:

Your HUD is just for display purposes. All it does is display some numbers in a fancy way.
Those numbers are provided by some model, in your case the weapon.
All the HUD needs to know is that weapon which holds a certain amount of ammo, which the HUD wants to display.

It’s is not concerned about anything else and nothing else is concerned about the HUD.
There’s no need to make it globally available.

 
Flag Post

Topic: Game Programming / This piece of code causes memory leak. Unsure, why.[as3]

I suggest you drop the bad habit of using a Global class.

A HUD is only a display. If the fuel gauge in your car fails and displays zero even though you still have fuel, can you still drive the car?
Why is your HUD involved in creating the bullets?

Is there a particular reason why you set your local variables to null?

 
Flag Post

Topic: Game Programming / What is a 'package'?

Yes, that would be an example of how packages are used.

Originally posted by Gamerboy98:

Try to give me another practical example if you can.

The classes of As3 itself are organised into packages, take a look:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/

 
Flag Post

Topic: Game Programming / Need your opinion for a just published game

The graphics look good, but they are not consistent.

The bird features a lot of gradients.
The landscape has something like cel shading.
And the bag with the hand is just a flat image with outlines.

Whatever your sources for graphics are, try to pick a consistent style next time.

Placing a tree so it is exactly halved by the edge of the screen does not look that nice.
Place it more into or out of the frame.
Better yet, make the background scroll according to the movement of the bag, to create more depth.

Performance is good. I have to agree with player_03.
You’d have to put some effort into making this lag. There’s nothing going on.

 
Flag Post

Topic: Game Programming / As3: Problem removing eventlistener

Originally posted by darkjonas8:

Well, i dont really get the blur filter you are talking about. I want a kind of trail after my character, not something like a gaussian blur.

Now I get it.
There’s a different approach to achieve the same effect that eliminates the need to remove the objects.
Have one bimap and draw your player into that bitmapdata every frame.

If also constantly apply the transform of reducing the alpha value, it will have the same effect – a trail behind the character.

 
Flag Post

Topic: Game Programming / As3: Problem removing eventlistener

Originally posted by darkjonas8:

but will i be able to simply remove the clip without any problem when the tweenlite transition is done?

You can specify a function to be called, when the animation finishes.
Did you consider applying the filter?

 
Flag Post

Topic: Game Programming / As3: Problem removing eventlistener

Originally posted by darkjonas8:

The only other reference i have to PlayerBlur is in my Game class, which is just:

                        var mb:PlayerBlur;
                        //and
			mb = new PlayerBlur;
			layer1.addChild(mb);
			mb.x = player.x;
			mb.y = player.y

You’d have to make sure this reference does not persist.
So if this isn’t a local variable, you should set it to null when you want to remove it.

That’s one reason why I would not let display objects remove themselves.
Also take a look at the other suggestions.

 
Flag Post

Topic: Game Programming / As3: Problem removing eventlistener

If you want to blur your player, why don’t you apply a blur filter to it?

If you want to change some property (in your case the alpha value) over time, use a tween library.
Tweenlite is a popular one, but there’s also a built in one:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/fl/transitions/Tween.html

As3’s Tween class is not so good, but it will get you started.

It is a lot more convenient than this DIY- ENTER_FRAME animation.
You can simply specify the beginning and end values and how long the transition should take.
In addition to that, you can specify what should happen when the animation is finished.

Regarding your original problem:
Trace out the alpha values to see what’s going on (you will probably be surprised)

 
Flag Post

Topic: Game Programming / No blank screen, debugging mode or trace statements seen

Try to create a new project.

 
Flag Post

Topic: Game Programming / No blank screen, debugging mode or trace statements seen

Originally posted by Gamerboy98:<br|

not only am I not getting the window, but I am not entering debugging mode and the strings in my trace statement are not appearing in the output window.

…and none of the other things you will try to accomplish in step whatever will work because you did not fix the problem you have with step 3.
And that’s why I suggested going through these steps in order.

If anything broke it’s your hope of it somehow magically working anyway even though you expected it to fail yourself.
Don’t blame me, it’s not my fault.

Thanks for changing the thread title. It helps to attract smart members of this forum.

After this off topic stuff, let’s focus on the problem again.
I’d still like to see whatever the output panel throws at you when you test the flash.
Just select everything and post it.

 
Flag Post

Topic: Game Programming / Problem with loop and buttons

You posted your code in a wrong way so it shows up strange.
But it looks like you are trying to assemble the names of your buttons.

There’s a better way: use an array. Put all buttons into one array and iterate over that.

If you have a bunch of similar things that you want to group together, use an array.
Put your enemies in an array.
Put your buttons in an array.

If you have a bunch of different things that you want to group together, use an object.
Put all the properties that an enemy has in an object.

As the enemies probably play an important role in your game, you’d want to create a class for them anyway.

 
Flag Post

Topic: Game Programming / No blank screen, debugging mode or trace statements seen

Originally posted by Gamerboy98:
Originally posted by NineFiveThree:

First of all, try to find some sane descriptive titles for your threads.
You state you cannot describe your problem easily, yet your post is only 2 sentences long.

I mean I can’t think of a good title for it. Besides, it stands out so I can get a quicker answer.

So you are spamming. Stop that. Generic thread titles do not stand out.
You don’t have to “think” of the title, just summarize your post in a few words.
“no window in FD when testing project”
“no blank screen in FlashDevelop”

Originally posted by Gamerboy98:

It says that there aren’t any errors, yet it doesn’t pop up.

Hello World! Doesn’t even show on the output screen.

“Hello world” is step 4 of this tutorial.
You have trouble with step 3.
You are supposed to follow those steps in the right order.

If you do not get an error message, what do you actually get in the output panel?
Please post everything.

 
Flag Post

Topic: Game Programming / Animating via code plus other issues

Well, you’re the programmer. You define what’s possible.

So you have some state (running).
And there’s something that causes this state to possibly change (hitting the attack button).
Now it’s your turn to say what should happen:
either “Ok, that’s fine, you can do this, we switch to the running-and-attacking state
or “dude, this is not going to work, we discard that hit of the attack button, because there’s no attacking while running. We stay in the running state
or “sure enough you can attack, but the running stops because of that, because there’s no running while attacking
or whatever else you want.

When you say there’s a “clash” it sound more like a lack of definition what’s supposed to happen.
Maybe you can explain a little more.

 
Flag Post

Topic: Game Programming / No blank screen, debugging mode or trace statements seen

First of all, try to find some sane descriptive titles for your threads.
You state you cannot describe your problem easily, yet your post is only 2 sentences long.

The tutorial states that there are things that can happen when you test the project:
Your Output Pane (at the bottom of your screen) will start to show some incomprehensible lines, describing what the compiler is doing. After a few moments, you’ll either get some kind of error message (Bad News!) or you’ll see a blank window pop up on your screen, with “Adobe Flash Player” in the top right corner. That’s your program. Let’s celebrate!

As you do not get a window, you want to check if you get any errors.
The flash player is obviously only executed if building your program was successful.

 
Flag Post

Topic: Game Programming / Using or sybmols in if conditions

If you want to identify strings, I suggest you make yourself familiar with regular expressions.

The reason that you have to re-enter “HOT” is caused by something else in your code.
You should show more of your code.

You can easily test this if statement separately, to check what causes the error.
Simply fill the array with the expected elements and execute the if statement to see what happens.

 
Flag Post

Topic: Game Programming / What is an 'Object' and 'Class'?

Originally posted by Gamerboy98:

So, should I sort of imagine it like this: A Class is a factory, functions and such in the class are workers, objects are products produced by the factory, instantiation is the process of making the product and instances are the individual products.

Or like this: The computer is a factory that can produce everything and the classes are orders received by the factory, while everything else is same.

I guess you are overcomplicating things.
Look at all the things around you (whatever they might be). Those are all objects. You can touch them. These are the things you can do stuff with.
Some of them are somewhat similar. You could come up with a category they belong to.

An example would be the keys on your keyboard.
Each individual key is different.

But you could put all of them into the category “keys”. They all share the common behaviour that when you push them, something happens.
These categories of things are classes.

 
Flag Post

Topic: Game Programming / Creating/importing .sav Files in AS3

Originally posted by Apple0726:

I heard using that method isn’t possible for web games for security purposes

The File class is limited to Air, because it can save at an arbitrary position without asking for permission.

 
Flag Post

Topic: Game Programming / What is an 'Object' and 'Class'?

A class is a type, like int. (integer)
An object is a value of a type, like 5 is a value of type int.

You can define your own classes, which according to the above means you can define your own types.
A class defines a type and therefore what the values (objects) of that type can do.

You are a human. You are an object of the class Human.
There are other objects of the same class, say your parents for example.

It seems like all humans have two arms two legs, a heart, etc.
That would al go into the class definition.
But there are other properties that can change from one object to the other, like skin, eye and hair color, name, place of birth.
There are also properties that change throughout the lifespan of the object, say spoken languages for example, ability to walk, age, etc.
These properties are the variables of the Human class.
They can vary in value from one object to the other, but each object has them.

I for one am an object of class Robot.

 
Flag Post

Topic: Game Programming / As3 incorrect number of arguements

What a mess.

People start class names with a capital letter and variable names with a small letter for a reason.
In your code it’s all over the place.

Following that convention, your code should look something like this:

var player:Player = new Player();
addChild(player);  // in your original code, you try to attach the class

variables small, classes big, ok?


player seems to be a more or less important object for your application.
I doubt that the only place you want to use it is the constructor of the Game (big letter, remember?) class.
Do not declare the player variable locally in the constructor, but class wide.

This holds true for all other variables in your Game class, declare them in the class block, as you do in the player class.
Make them all private and give all of them a type.


 addEventListener("enterFrame",enterFrame);

Always use the defined constants. You sometimes do and sometimes you don’t. try to be a little more consistent.
This prevents you from mistyping the string, which is one of those hard to find errors.

 addEventListener(Event.ENTER_FRAME,enterFrame);

var b2:block2;
var b3:block3;
var b4:block4;
var b9:block9;
var b6:block6;
var b7:block7;
var b8:block8;
var b11:block11;
var b12:block12;
var b5:block5;

If you need multiple variables of a certain type, create an array.
Such duplicated code is hard to maintain and due to the additional inconsistencies (what’s with block1?) hard to read.


for (var i:Number = 0; i < level1data.length; i++)
                {
                for (var j:Number = 0; j < level1data[i].length; j++)
                {
                if (level1data[i][j] == 10)
                {
                b2 = new block2;
                        addChild(b2);
                        b2.x = tileSize * i;
                        b2.y = tileSize * j;
                }
                if (level1data[i][j] == 3)
                {
                b3 = new block3;
                        addChild(b3);
                        b3.x = tileSize * i;
                        b3.y = tileSize * j;
                }

This copy and paste stuff will cause headaches.
Prevent duplicated code if possible.
You could easily turn this into generic code.


The indentation of your code is not that good.
One main point of services like pastebin is to maintain that indentation.


An additional option to passing a reference to Player in order to call a function on Game, Player could dispatch an Event, that Game would listen for.
This is possibly preferable.

Originally posted by aenil333:

player class doesnt seem to be imported in game class that could cause the error when trying to instantiate it

As both classes are in the same package, I don’t think this is the issue.

 
Flag Post

Topic: Game Programming / AS3 Applying

Originally posted by aenil333:

You dont agree to what… you mention flash builder is better… but made by adobe…
?!?

I do not agree to what I quoted.

also see Ambibtious post