Be a Supporter!
Response to: Some animation i created... Posted September 6th, 2014 in Animation

At 9/6/14 03:11 PM, GrahamNG wrote: The animation bbs is littered with self-promotion.

So true.... It makes it worse when they are self-promoting themselves for things outside of newgrounds....

Response to: Managing arrays Posted September 6th, 2014 in Game Development

At 9/6/14 08:38 AM, Barzona wrote:
At 9/5/14 06:47 PM, Hero101 wrote:
I've got about 10-15 different arrays that hold anything that has to be tested multiple times. The only things I don't add to an array would be, like, the Player and the background. Arrays are your friend and you shouldn't fear them.

I wouldn't say I fear them I'm just uncomfortable with them. I definitely need more practice with them.

I'm surprised nobody got to your array questions.

Haha yeah my post kind of got taken into another direction. That's okay though as I did need help learning how to handle collisions with math. Killed two birds with one stone with this post :)

Thank you for all of your input it's much appreciated :)

Response to: Managing arrays Posted September 5th, 2014 in Game Development

At 9/5/14 09:25 PM, Etherblood wrote:
At 9/5/14 09:19 PM, Hero101 wrote: What I don't understand is where exactly it is returning those values (true/false) in the rest of the code and what to do with it. Is it returning it to some other function or variable else where in the code?

Sorry to sound so amateur-ish...
After defining this function you can do your coolision tests by calling it.
Like this for example:

if (aabbIntersection(objectA.getBounds(null), objectB.getBounds(null)))
{
//handle object intersection here
}

This code would be placed in your collision loop

Oh this makes it more clear to me about using "return" and how parameters in a function work together - thank you.

Why are the objects bounds null in the code above? Is that due to what was "Return"-ed in checking for a collision?

Response to: Managing arrays Posted September 5th, 2014 in Game Development

At 9/5/14 08:58 PM, Etherblood wrote:
At 9/5/14 08:42 PM, Hero101 wrote: I looked into getBounds. I will have to play around with it and give it a go. Probably won't see the whole picture of how it all works until I try it out myself. If you're bored you could always type up some pseudo code as a visual aid for me... Appreciate your help :)
I made 3 versions, they all do the same, hope I didn't include typos, ask if you have questions.

Makes sense to me. I haven't done any tests with "Return" before. All I know is that it returns a value. So I can see that it's returning a value for a boolean where true means it is intersecting.

What I don't understand is where exactly it is returning those values (true/false) in the rest of the code and what to do with it. Is it returning it to some other function or variable else where in the code?

Sorry to sound so amateur-ish...

Response to: Managing arrays Posted September 5th, 2014 in Game Development

At 9/5/14 08:24 PM, Etherblood wrote:
At 9/5/14 08:04 PM, Hero101 wrote:
You should define this points relative to your objects coordinates for better quality collision, but for starters you can just use the movieclips/sprites bounding boxes.

You can use the getBounds(coords) method of your objects to get their bounding boxes, use the same object as coordinate parameter.
You now have 2 rectangles, theese already have getter for the upper left and the lower right point, use them.

I looked into getBounds. I will have to play around with it and give it a go. Probably won't see the whole picture of how it all works until I try it out myself. If you're bored you could always type up some pseudo code as a visual aid for me... Appreciate your help :)

Response to: Let's Talk About the NG Layout! Posted September 5th, 2014 in NG News

@TomFulp

Any chance of allowing code tags in PM's in the future? Sometimes it is easier to work out code with one individual through a PM rather than a constant posting to a forum post.

Response to: Managing arrays Posted September 5th, 2014 in Game Development

At 9/5/14 07:21 PM, MSGhero wrote:
At 9/5/14 07:20 PM, Hero101 wrote: Isn't that what aabb collision is? Every source I find on rectangle collision seems, well, not so simple so I have a hard time understanding it. Maybe I should try to find a youtube video that could break it down for me...
"AABB collision" first link: https://www.youtube.com/watch?v=ghqD3e37R7E

That had to be the most simple explanation out there. How do you define the corners of an object though through code (like in the video Ax, Ay, AX, AY)? Are they just Points? If so, is there another way than me physically defining the points myself?

Response to: Managing arrays Posted September 5th, 2014 in Game Development

At 9/5/14 07:28 PM, Etherblood wrote:
At 9/5/14 07:20 PM, Hero101 wrote:
Yup, thats aabb collision, it's really simple once you understood how it works, fast, and already very useful.
My platformer uses only aabb and I didn't have to bother to use quadtrees or similar because the levels are relatively small.
I can try to explain how to detect and solve intersections using aabb's if you want.

By all means feel free to explain - I'm all ears (or is it all eyes in this case?). Or PM if that would be easier.

Response to: Managing arrays Posted September 5th, 2014 in Game Development

At 9/5/14 07:11 PM, MSGhero wrote:
At 9/5/14 07:09 PM, Hero101 wrote: Don't know what ray casting is - will have to look into that as well.
Don't, just do simple rectangle collisions.

Isn't that what aabb collision is? Every source I find on rectangle collision seems, well, not so simple so I have a hard time understanding it. Maybe I should try to find a youtube video that could break it down for me...

Response to: Managing arrays Posted September 5th, 2014 in Game Development

At 9/5/14 07:04 PM, egg82 wrote:
At 9/5/14 06:47 PM, Hero101 wrote:
It doesn't matter much either way in that scenario. The only thing you can do is reduce the amount of collision checks with quad trees and use fast/efficient collision detection using math (circle/circle and vector/vector collision) and lines (ray casting)

What are quad trees?

I'm tired of using hitTestObjec (or Point) for collision detection as there is no good way to, for example, use them to stop a player from running through walls (forced to just stop players velocity which sucks) - I really want to learn how to do it using math. I looked into aabb collision detection and I can't wrap my head around it at all...

Don't know what ray casting is - will have to look into that as well.

Response to: Looking for feedback and critiques Posted September 5th, 2014 in Animation

At 9/1/14 05:25 PM, aobomb wrote: I was looking for a place to post WIPs for critique and comments towards improving. I'm not as interested in views as i am as much as I am in critical feedback.
I've posted some work in the animation portal and feel like that its more reserved for finished products over WIPs.

Anyone have suggestions on the best place to chew the animation fat?

Thanks!

Still feels like you are trying to get views.... If you want feedback you should get it before uploading it anywhere. There used to be a WIP section here on NG but it's no longer available. Next time upload it to the dumping grounds (that trash bin looking symbol at top of webpage by your username). Then after it is up there copy the URL and post it here in the forum to ask for critiques.

As for your feedback: There isn't too much happening in the animation, but for what there is everything looks solid. Smooth, fluid animation, and nice touches on subtly to make the character feel alive. Good job.

Managing arrays Posted September 5th, 2014 in Game Development

I'm still getting used to arrays/loops. My last game was my first attempt using them. It was simple as I just used it for one item and there was 5 items in each level. So I simply added them to array each level, removed them from array as they were collected, and added them back to array with each new level.

So what I'm wondering is with bigger projects do you guys put everything into separate arrays?

For example, lets say all items collected just increased your score and there are 5 different types of items. Now say for the first couple of levels there is only one type of item - I can't have all the other collectible items in that same array since they won't be present in the game at the time and thus it would throw an Error 1009 at me correct? Or am I wrong?

The more I learn about arrays/loops it seems like any game would end up with a ton of arrays/loops for such things as items, enemies, walls, pretty much anything checking for a collision.

Curious as to how you guys go about managing your arrays. Do you create them as you need them? Or create them from the start and update them to the needs of each level?

Thanks in advance guys.

Response to: A little clarification please Posted September 4th, 2014 in Game Development

At 9/4/14 12:34 AM, Etherblood wrote:
At 9/3/14 11:55 PM, Hero101 wrote:
If you really only want to use the brick you could just set its reference to null and check for null each time before collision checking.

This worked :) But I still want to look into your array suggestion. Still getting used to arrays/loops so I could use more practice with them.

Response to: A little clarification please Posted September 4th, 2014 in Game Development

At 9/4/14 12:34 AM, Etherblood wrote:
At 9/3/14 11:55 PM, Hero101 wrote: So how should I go about achieving what I am trying to do? What would you suggest?
One possible solution would be:
Keep an array of objects to hitTestAgainst and add the brick to it,
loop through the array each frame and test its elements against the key.
Remove objects from the array when removing them.

If you really only want to use the brick you could just set its reference to null and check for null each time before collision checking.

Interesting idea with the arrays I will have to try it :) I think I tried setting it to null.... maybe I'm doing it wrong?

Is it:

if (brick = null)

OR

if (brick == null)

OR 

if (brick === null)

I played with each one and it didn't seem to work. Actually come to think of it I think I forgot to set the reference to null hahaha

Response to: A little clarification please Posted September 3rd, 2014 in Game Development

At 9/3/14 11:41 PM, MSGhero wrote:
At 9/3/14 09:08 PM, Hero101 wrote: Why is that?
hitTestObject looks at the bounding boxes when colliding. Removing the graphical brick doesn't stop it from having a bounding box, and like was said in the other thread, objects retain their properties even when removeChilded.

So how should I go about achieving what I am trying to do? What would you suggest?

A little clarification please Posted September 3rd, 2014 in Game Development

So I was bored and decided to play around with some code. Made a key fall from the sky and when it hit this brick on stage it would stop falling. I added an event listener to the brick so that if I clicked it it would be removed.

What I discovered was that it didn't matter if I removed the brick before or after they collided - either way the key would stop at the brick and just stay there. So it hits brick, stops, I remove brick and it doesn't keep falling. I remove the brick before the key hits it and the key still stops where the brick used to be.

Why is that?

Here's the quick little code I was playing with:

public function GameManager() 
		{
			addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
		}
		private function onAddedToStage(e:Event):void
		{
			brick = new Brick();
			addChild(brick);
			brick.x = 275;
			brick.y = 250;
			
			key = new Key();
			addChild(key);
			key.x = 275;
			key.y = 50;
			
			brick.addEventListener(MouseEvent.CLICK, onBrick);
			addEventListener(Event.ENTER_FRAME, loop);
		}
		function onBrick(e:MouseEvent):void
		{
			removeChild(brick);
		}
		function loop(e:Event):void
		{
			key.y += vy;
			
			if (key.hitTestObject(brick))
			{
				vy = 0;
			}
			if (!key.hitTestObject(brick))
			{
				vy = 2;
			}
		}

	}
	
}
Response to: Add back elements to containers? Posted September 3rd, 2014 in Game Development

At 9/3/14 04:13 PM, MSGhero wrote:
At 9/3/14 04:02 PM, Hero101 wrote: Oh how interesting. Never thought of trying that. Just to be clear when you say push them into another array - you are just talking about the bricks, right?
Yes, storing arrays in other arrays doesn't make sense here.

Does it every make sense to store an array inside of another array? If so, could you give me a scenario where one would consider doing that?

Response to: AS3 dynamic variable in function Posted September 3rd, 2014 in Game Development

At 9/3/14 02:02 PM, MintPaw wrote:
At 9/3/14 02:18 AM, Xombiehacker wrote:
At 9/3/14 12:04 AM, MintPaw wrote:
It's just versatile, and it's highly suggested that you learn the longhand way of doing things before you choose shorten them.
Learn the long way, learn how it works, learn why it works. Then you can massively optimize it.

Another example is this:

onScreen = false;
if (player.x > 0)
{
if (player.x < stageWidth)
{
onScreen = true;
}
}

Ya see how I could write that and later optimize it to:

onScreen = player.x < stageWidth && player.x > 0;

But it's much harder for a newbie to write it like that off the cuff. So you'd better learn the long way first.

So very true. To be honest it didn't even cross my mind that it could be optimized that way. Which makes sense since I'm technically still a newbie :P but I definitely see the benefit to learning the long way first.

Response to: Add back elements to containers? Posted September 3rd, 2014 in Game Development

At 9/3/14 11:13 AM, MSGhero wrote:
At 9/3/14 01:51 AM, Hero101 wrote:
At 9/3/14 01:39 AM, MSGhero wrote:
At 9/2/14 11:34 PM, Hero101 wrote:
Loop through your bricks.
Push them to one array.
Push them to another array.
Manipulate the first array however you want.
Use the second array to refresh the first one and refresh the container.

You have an array, you don't need to save bricks in a variable. You save them in the array by pushing them and not removing them.

Oh how interesting. Never thought of trying that. Just to be clear when you say push them into another array - you are just talking about the bricks, right?

Or do you mean pushing the array containing the bricks into another array? Although I don't know the purpose of storing an array in another right just yet...

Response to: AS3 dynamic variable in function Posted September 3rd, 2014 in Game Development

At 9/3/14 02:24 AM, Xombiehacker wrote:
At 9/3/14 12:00 AM, Barzona wrote: Well, if you're adding something from the library, I don't think you'd need "NewName" in your parameters. "InstanceName" which is the class name is all you'd need in your arguments, I think.
I would like to have a new name, basically what I'm getting at is reinstating the attachMovie() function from AS2, as AS3 seams to be missing it >.>
My original code looks like

function AttachMovie(InstanceName,NewName,Depth:Number,XCoordinate:Number,YCoordinate:Number){
var NewName = new InstanceName();
addChildAt(NewName,Depth);
NewName.x = XCoordinate;
NewName.y = YCoordinate;
}

I didn't want to write it before because people have some religious attachment to AS3, where as I see many flaws in it, though with the receeding use of AS2, I'd like to start using AS3 but outfit it to look and function more like AS2 so I can properly function within it's bounds

You only see flaws in it because you don't understand it. In time it will all make sense and you will see how it is more effective and flexible than AS2.

Like MintPaw said, why are you trying to do it this way? It's like you are trying to cut corners or pack every thing so tightly like your example above - doing so won't allow flexibility down the line. Do what Barzona suggested and declare the rest. If you are afraid of your code getting overcrowded then you should look into using classes with AS3.

Best of luck to you.

Response to: Add back elements to containers? Posted September 3rd, 2014 in Game Development

At 9/3/14 01:39 AM, MSGhero wrote:
At 9/2/14 11:34 PM, Hero101 wrote:
Just add back the old ones...you're destroying a brick then putting an identical one in its place.

I'm trying to figure out how to do that but have been unsuccessful so far.... I don't know how far off the mark I am with the code I posted above (minus what I did with removing and then re-adding a new instance of the item container).

Save all bricks.

What exactly do you mean by saving them? Like store each item in the container in a variable (if so, how?)?

Response to: Add back elements to containers? Posted September 2nd, 2014 in Game Development

Also realized that in the block of code that fills the array with the items I could just re-add the new instance of the container containing the items before refilling the array like so:

function fillBricks():void //Fill array with bricks that are in brick container (brickCon)
		{
			var a:Number = 0;
			for (a = 0; a < brickCon.numChildren; a++)
			{
				bricks.push(brickCon.getChildAt(a)); //Add bricks to an array
			}
			if (bricks.length < brickConAmount) //If brick array is less than starting amount of bricks in container
				{
					removeChild(brickCon);  //THESE NEXT 3 LINES IS WHAT I WAS TALKING ABOUT
					brickCon = new BrickCon();
					addChild(brickCon);
					for (a = 0; a < brickConAmount; a++)
					{
						bricks.push(brickCon.getChildAt(a));
					}
				}
		}

Not sure if removing item container, declaring a new one, and adding it back is the proper way to go about what I'm trying to do (get items back on stage in case level is replayed again) but it works...

Response to: Add back elements to containers? Posted September 2nd, 2014 in Game Development

At 9/2/14 08:53 AM, MSGhero wrote:
At 9/2/14 01:37 AM, Hero101 wrote: Unless I'm missing something...
You hard-coded their positions by placing them in flash pro. When you add a symbol to a thing, you're addChilding it and setting its position. Don't worry about for in loops, that was pseudocode.

Gotcha. So a regular for loop would work just fine then instead of a for...in loop? I've read the AS3 API documentation on all the types of loops and while I understand when using a for, while, do loop would be necessary, I don't quite understand when I would need to use a for...in loop (same goes the for...each loop).

Response to: Add back elements to containers? Posted September 2nd, 2014 in Game Development

At 9/2/14 05:12 PM, MintPaw wrote: Properties are properties, if myClip.x is crated because you placed the clip in the FlashIDE, then you removeChild() it, it will still retain the properties that it had even though it was set by the IDE. I know it's confusing, these are some weird meta-programming things you should really be having to think about, I hope soon you switch out of the IDE, it's important in learning to program.

Ok thank you guys for all of your input. I do plan on making the switch out of the IDE very soon. I was planning to go to Flash Develop first, but recently my PC went down. Until I can get it repaired I have been working on my Mac. So I will have to try out Flash Builder. Hopefully that is just as good as Flash Developer.

Response to: as2 to as3 onEnterFrame? Posted September 2nd, 2014 in Game Development

At 9/2/14 12:39 AM, MintPaw wrote: Now, you could nest the function within the listener like you did in AS2:
AS3:

addEventListener(Event.ENTER_FRAME, function stuffToDo(e:Event):Void
{
// do stuff
});

Any benefit to nesting it? I've always kept the listener and function separate.

Response to: Add back elements to containers? Posted September 2nd, 2014 in Game Development

At 9/2/14 01:25 AM, MintPaw wrote: When you removeChild something it doesn't magically lose it's properties.

I understand the issue with not hardcoding everything. If I have a mc container that has all of the coins placed around in it - it doesn't have their locations saved anywhere in code... thus it doesn't have it's location properties since I didn't hardcode each and every one of them in a class...

Unless I'm missing something...

Response to: Add back elements to containers? Posted September 2nd, 2014 in Game Development

At 9/2/14 12:09 AM, MSGhero wrote:
At 9/1/14 11:54 PM, Hero101 wrote: Is that what you guys do? addChild every single item to the level? Seems like a ton of code if say there were 100 items in the level.
for (coin in coins) container.addChild(coin);
for (plat in platforms) container.addChild(plat);
for (item in items) container.addChild(item);

Could be a thousand objects, loops are your friends.

I haven't used a for...in loop before so I will have to practice around with them. I'm assuming the "coins" in your code above is an array that the coins are stored in. But using your code above how would I position each coin after addChild-ing them? Looking at your example it would just addChild them all to the same location in the container...

Response to: Add back elements to containers? Posted September 1st, 2014 in Game Development

At 9/1/14 11:51 PM, MintPaw wrote:
The solution is to addChild them to the screen. I guess you could check if they've been removed and only readd them then.

Is that what you guys do? addChild every single item to the level? Seems like a ton of code if say there were 100 items in the level.

Add back elements to containers? Posted September 1st, 2014 in Game Development

Say I have a container (mc) that I add to my game that contains a certain type of collectable (lets just say coins). I add that to my level container. I create an array for the coin container. Every time the player touches a coin I removeChild the coin from the container and remove it from the array as well.

All of this works fine. But say the player beats the game and they click replay. All of the coins are no longer in the coin container because they were removed from previous game session (through removeChild).

Is there a way around this without having to add all the coins back into the container manually? Seems a bit extreme to do it this way if say there were 100 coins in the container.

Would repeating the code , for example, coinContainer = new CoinContainer when the replay button is clicked fix this?

Any feedback would be greatly appreciated. I'm still relatively new to using arrays and loops.

Response to: multiple characters in a platformer Posted September 1st, 2014 in Game Development

At 8/31/14 07:31 PM, halfblue3 wrote: so, the code might look like:(sorry, i am using as2, but i think it isn't really important to use as3 or as2 for the code below because it is just conditional statements)

if(mc1._visible = true){
//code for motion
}
else{
//code for motion
}

Are all these Character's NPC's or something the player physically controls.

If it is something the player physically controls will there ever be a chance where more than one will be on the stage at the same time? If no, then you don't need the if/else statements if you do what I mentioned before.

If they are just NPC's (say enemies) that are going to have very different behaviors then give them their own class. (I don't know AS2 so I don't know if classes exist in AS2).