00:00
00:00
Newgrounds Background Image Theme

SpeakyDooman just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

..::NG's Code Challenges::..

1,856 Views | 20 Replies
New Topic Respond to this Topic

..::NG's Code Challenges::.. 2012-11-24 03:29:55


..because I couldn't think of a more creative name, I welcome you to

..::Newgrounds' Code Challenges::..

About:

The Newgrounds' Code Challenges (or NCC for short) are a collective effort to raise the bar for flash and web games. Despite how far flash has come, almost all games are dead simple and have little or no technical innovation, and yet you can find amazing programmers that can create all these breathtaking things, but they just don't know what to do with them. The NCC is here to fix that.

Whether you're an experienced programmer with an itch for a challenge, or you're a game designer looking for fun new mechanics. Or even if you're a new programmer who wants to learn something. Everyone is welcome!

How it works

Every week, a theme or a certain mechanic will be announced, and people will have up to a week to submit their creations. The goal is to try to create the mechanic so that it looks amazing, such as a water ripple effect, as well as being fast enough to be practical for use in a game.

This is both to challenge ourselves as programmers, and to challenge what can be done with flash.

Rules

We want to encourage innovation and experimentation, as such, there are little rules and regulations. If you're experimenting with something, and come across a completely different, but still awesome, mechanic, feel free to submit that! Who knows what may come out?

There are only two rules.

1-This is a submission thread. Please do not post any discussion here. Discussion will be in a separate discussion thread to be posted below.
2-You are required to share your code so that other people can learn from it. If you've got that baby locked up, at least share your method/pseudo-code.

-You are allowed to make revisions and update your submission whenever you like. The deadline is really only there so we know when to move on to a new challenge.
-If you see an old challenge that you missed, feel free to enter! Maybe you have some new insights or methods to contribute.

How to submit

Just upload your file(s) on NG's dump or any similar upload service, and post it below. You should also post your source either as an .fla or zip file, or just put it on pastebin if it's a small file/function.

The first challenge will be posted imminently.

Response to ..::NG's Code Challenges::.. 2012-11-24 03:42:22


===Challenge #1===

Smoke

I thought we'd kick this off with something a bit ambitious. Smoke has always been a REALLY tricky thing to create, no matter what platform you're on, but I have seen no game with a really impressive smoke effect.

The best one I could find was The Company of Myself:

But its smoke effect is just a pre-rendered bitmap sequence!

Its prequel has smoke, but still not as impressive:

So your goal is to create an awesome smoke effect. Whether it's for a character who would be smoking a cigarette with wind pushing the smoke, or if it's for a poisonous gas that diffuses outwards. Whether you're going for practically over realism or vice versa.

Feel free to submit at any time.

Response to ..::NG's Code Challenges::.. 2012-11-24 05:12:35


Triple post, but I wanted to add:

In the last game jam I wanted to make a cool smoke effect. So I searched on the web for an algorithm or a tutorial, and I couldn't find a single Actionscript tutorial with a decent smoke effect. The ones I did find were all in C++, and since they had no web preview, it was hard to tell which had the effect I wanted at a glance.

So let's change that!

Response to ..::NG's Code Challenges::.. 2012-11-24 06:14:30


Chugs along quite slowly at first but it soon takes effect:

http://www.newgrounds.com/dump/item/fafe426c84175e37331dd035 b0eb3d7f

This is all dynamic btw! I'll release the source code and non-obfuscated SWF once I see some effect going in this thread ;)

Made and perfected in 10 minutes


.

Response to ..::NG's Code Challenges::.. 2012-11-24 11:59:28


Response to ..::NG's Code Challenges::.. 2012-11-24 19:51:12


Sure, why not. Took about 20 minutes.

NCC 1 - Smoke

Response to ..::NG's Code Challenges::.. 2012-11-27 08:10:32


I'll be the first to post my source. Here's my submission:

Preview

Click to create smoke.

FLA (CS4) + .as file

AS File

Response to ..::NG's Code Challenges::.. 2012-12-08 02:33:39


===Challenge #2===

Fuzzy Logic/Path Finding

For some reason, there's a stunning lack of good path finding in flash games. And the games that do have path finding usually have their bots moving in these systematic and robotic way.

Your goal would be to make a bot that can find its path, but also looks more believable. Because it would be really cool to see natural-behaving AI in a game. (Could even be a game in itself! Trying to interact with these unpredictable AI)

This is really a more open-ended challenge, but here are some things to keep in mind:

-A* is overrated, there are easier/faster ways to do path finding with Dynamic Programming
-Props to whoever can make his path finding work in a dynamic environment, where I can either draw walls or move objects
-Make an AI that learns. We're not making self-aware AI, learning really isn't much more than analyzing cost, recording patterns and choosing the best output. A very easy example is, for a bot the smoother the path is, the greater the chance of it going through a wall. So you could keep iterating at run time, smoothing the path then checking if it hit anything, and choosing the smoothest path that doesn't hit. There you go! You made a bot that learns the smoothest path.

Finally, if you've always wanted to try path finding but haven't gotten the chance or the excuse, there you go!

..::NG's Code Challenges::..

Response to ..::NG's Code Challenges::.. 2012-12-16 04:06:11


I guess I really didn't explain the challenge well enough, as there was no "specific' challenge, but here's my attempt:

Link

The bot will try to go to the *, which is the goal. Click on nodes to add obstacles.

This is not using A*, and you can see how it doesn't calculate from point A to point B, but rather it tells you the shortest path from any point on the grid to the goal. (You can also see how it lags as it recomputes the path when you click with the mouse)

So here's a more refined challenge:

===Challenge #2.1===

Dynamic Path Finding

The goal: Make a bot where I draw the obstacles, and it finds its path. The best submission would be one where you can't tell if a grid is being used for path finding.

One way is to go around and place nodes only where there is no collision with ground for example. This is to show that path finding can work for art-based games as well tile-based.

And it looks really cool!

So, who's in? (Also, thoughts on my attempt!)

Response to ..::NG's Code Challenges::.. 2012-12-16 12:57:45


I'm in.
I've been working on it for a few days coz I have to build one anyway.
I'm using DijkstraĆ¢EUTMs algorithm as well.
I was aware of the problems with A* but didn't think much about it because I was assured it was top notch lol.
My solution receives a bitmapdata and raw pixel co-ordinates as input.
So technically it's not tile based in the sense that you don't have to type out a 2D array of values.
But it does create a tile map from the bitmap data and you can specify the tile size in pixels.

So I'm recording the characters memory as a bitmapdata and passing that to my path finder.
This is to create the illusion of "learning" the best path because he will try to find it from his memory and get the wrong result unless he's seen the entire level.

I'm still working on the character movement but I can't wait to show it off.
Late submissions are fine right?

Response to ..::NG's Code Challenges::.. 2012-12-16 18:41:02


Right, here we are:

http://www.newgrounds.com/dump/item/be1c13848a1e9d6da1070378 0b4fd657

Click the screen to send him on his way.

There's no collision detection.
This is about as good as I could get the character motion by tweaking.
If I was using this solution in a project I'd make the wall blocks larger than the graphics which the player sees.

The ridiculous memory usage is caused by the dynamic mask class which I'm using to represent the characters vision.
That image is drawn into his memory every second frame and the path is calculated from his memory.

Response to ..::NG's Code Challenges::.. 2012-12-16 21:44:21


At 12/16/12 06:41 PM, ScrumTurd wrote: http://www.newgrounds.com/dump/item/be1c13848a1e9d6da1070378 0b4fd657

well done, sir!

oh, have an error.

TypeError: Error #1010: A term is undefined and has no properties.
	at PathFinder/firstStep()
	at PathFinder/getPath()
	at Main/wallCheck()
	at Function/http://adobe.com/AS3/2006/builtin::apply()
	at com.greensock::TweenMax/renderTime()
	at com.greensock.core::SimpleTimeline/renderTime()
	at com.greensock::TweenLite$/updateAll()

clicked in a possibly out-of-bounds area (top-right of the screen)


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to ..::NG's Code Challenges::.. 2012-12-17 08:00:22


At 12/16/12 09:44 PM, egg82 wrote:
At 12/16/12 06:41 PM, ScrumTurd wrote: http://www.newgrounds.com/dump/item/be1c13848a1e9d6da1070378 0b4fd657
well done, sir!

oh, have an error.

TypeError: Error #1010: A term is undefined and has no properties.
at PathFinder/firstStep()
at PathFinder/getPath()
at Main/wallCheck()
at Function/http://adobe.com/AS3/2006/builtin::apply()
at com.greensock::TweenMax/renderTime()
at com.greensock.core::SimpleTimeline/renderTime()
at com.greensock::TweenLite$/updateAll()

clicked in a possibly out-of-bounds area (top-right of the screen)

Yeah, it's buggy as hell if you'll excuse the pun.
That one is probably caused by the character being outside the screen or on top of a coloured pixel.
It's more stable at a higher framerate.

How do you get run time error messaging from a stand alone flashplayer?

Response to ..::NG's Code Challenges::.. 2012-12-17 14:14:29


Ok I took out the learning process coz the mask was getting in the way of experimentation.
I managed to get this running with a tile size of 8x8 pixels but it's back at 20 now.
Made the path less orthogonal by cutting nodes until a collision is found:

http://www.newgrounds.com/dump/item/df978ecbd17e2065e563384b cada08eb

Response to ..::NG's Code Challenges::.. 2012-12-17 17:21:34


At 12/17/12 08:00 AM, ScrumTurd wrote: How do you get run time error messaging from a stand alone flashplayer?

oh, I didn't see the post.
I set Chrome to use the debug player.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to ..::NG's Code Challenges::.. 2012-12-17 17:23:31


At 12/17/12 02:14 PM, ScrumTurd wrote: http://www.newgrounds.com/dump/item/df978ecbd17e2065e563384b cada08eb
ReferenceError: Error #1069: Property distance not found on String and there is no default value.
	at PathFinder/pathFind()
	at PathFinder/getPath()
	at Main/mClick()

o.o


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to ..::NG's Code Challenges::.. 2012-12-17 18:26:11


ReferenceError: Error #1069: Property distance not found on String and there is no default value.

Ah I know what that is.
Happens if you click on an empty pixel of a filled tile.
Cheers dude,

Response to ..::NG's Code Challenges::.. 2012-12-18 07:33:35


ReferenceError: Error #1069: Property distance not found on String and there is no default value.

Wait a minute, if infinity is stored as a string, then how come I can do numerical comparisons with it?

Response to ..::NG's Code Challenges::.. 2012-12-18 09:21:17


At 12/18/12 07:33 AM, ScrumTurd wrote: Wait a minute, if infinity is stored as a string, then how come I can do numerical comparisons with it?

I dunno, but I do know this: String is final, and neither String.distance nor myString.distance exists.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature

Response to ..::NG's Code Challenges::.. 2012-12-18 12:16:04


At 12/17/12 02:14 PM, ScrumTurd wrote: Ok I took out the learning process coz the mask was getting in the way of experimentation.
I managed to get this running with a tile size of 8x8 pixels but it's back at 20 now.
Made the path less orthogonal by cutting nodes until a collision is found:

http://www.newgrounds.com/dump/item/df978ecbd17e2065e563384b cada08eb

I know I said no discussion in this thread, buuuuut

That looks really awesome.

You should make a version with the grid and the line hidden and it'd look like super awesome path finding!

Response to ..::NG's Code Challenges::.. 2012-12-18 12:22:38


TypeError: Error #1010: A term is undefined and has no properties.
	at PathFinder/evenShorterPathArray()
	at PathFinder/getPath()
	at Main/mClick()

clicked in the same box as the current path's end (the point of the bug) - I assume you simply didn't account for a zero.


Programming stuffs (tutorials and extras)

PM me (instead of MintPaw) if you're confuzzled.

thank Skaren for the sig :P

BBS Signature