00:00
00:00
Newgrounds Background Image Theme
Upgrade Your Account!

HO HO HOPE you become a Newgrounds Supporter this year!

We're working hard to give you the best site possible, but we have bills to pay and community support is vital to keep things going and growing. Thank you for considering!

Become a Supporter so NG can see another Christmas!

The Flash 'Reg' Lounge

3,086,175 Views | 60,186 Replies
New Topic Respond to this Topic

Response to The Flash 'Reg' Lounge 2013-02-17 19:53:51


Just spent wayyyy longer than I wanted to on a dumb carousel. I'd say it's taken the best part of 7 hours to get the thing working exactly as I want it and hooked into the game it was built for

Here is the prototype version (which is now in a [cleaner] class of it's own in the final product)

http://www.newgrounds.com/dump/item/761f732f26871e2e297a5407 8aa50d01

Sorry if no one cares, just thought I'd start throwing some stuff I'm doing in my spare time up here so people can have a nose if they like :)


- Matt, Rustyarcade.com

Response to The Flash 'Reg' Lounge 2013-02-18 00:43:54


80 million particles and 69 hour render time. This is how we will make smoke effects.

Response to The Flash 'Reg' Lounge 2013-02-18 01:14:16


At 2/17/13 07:53 PM, Rustygames wrote: Just spent wayyyy longer than I wanted to on a dumb carousel. I'd say it's taken the best part of 7 hours to get the thing working exactly as I want it and hooked into the game it was built for

Here is the prototype version (which is now in a [cleaner] class of it's own in the final product)

http://www.newgrounds.com/dump/item/761f732f26871e2e297a5407 8aa50d01

Sorry if no one cares, just thought I'd start throwing some stuff I'm doing in my spare time up here so people can have a nose if they like :)

That runs actually pretty well. I think carousels in general are a pain... i have dealt with them on the css/js side and they are just as annoying, particularly to get them to work with mobile. It's almost more worthwhile to build them from scratch. HMPH.


None

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-18 01:19:12


At 2/18/13 12:43 AM, MSGhero wrote: http://www.newgrounds.com/portal/view/611392
80 million particles and 69 hour render time. This is how we will make smoke effects.

that was neat. Dunno how practical but neat anyway. That reminds me though... maybe im too artsy to put my head around it but is it really impossible to make things truly 'random' in the programming world... i mean is there such a thing as random to begin with? like when ive told programmers to 'make it random'.... do you like instantly dismiss the idea of 'random' and come up with something that has enough breathing room to feel 'random' or is there a such thing as random... also i might have had some drinks today. but regardless, that has been on my mind. i think about stuff while i goto and come back from work and sit on the train for an hour.


None

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-18 01:41:50


At 2/18/13 01:19 AM, Luis wrote: that was neat. Dunno how practical but neat anyway. That reminds me though... maybe im too artsy to put my head around it but is it really impossible to make things truly 'random' in the programming world... i mean is there such a thing as random to begin with? like when ive told programmers to 'make it random'.... do you like instantly dismiss the idea of 'random' and come up with something that has enough breathing room to feel 'random' or is there a such thing as random... also i might have had some drinks today. but regardless, that has been on my mind. i think about stuff while i goto and come back from work and sit on the train for an hour.

I've thought about that too some. It's like how a coin flip or die roll is "random" when there's a predetermined result when all the physics gets worked out. Same thing with programming, it just picks the next number in a list. The seed could be based on the current time or the location of a star or something, but it could be figured out.

It's more along the lines of being "random enough." A coin flip is random enough for the superbowl. Dice rolls are random enough for board games, and the random function is random enough for a game. There was one thing I saw where the guy had 200 numbers in an array, and his random function literally just picked the next one in the list and looped back to the start.

I saw this thing on tv where a bunch of labs every second submit a random number from a supercomputer (0-255 I think), and normally the distribution is more or less even. But when shit is about to go down, like an hour before 9/11 and at other times, most of the values were the same...

I'm not sure how quantum computing is supposed to work, not sure if the value is "truly random" or just so random enough that we don't have the means to calculate the result. The same could be said for how the mind randomly chooses, I guess.

Midnight musings

Response to The Flash 'Reg' Lounge 2013-02-18 10:48:37


At 2/18/13 01:19 AM, Luis wrote: hat reminds me though... maybe im too artsy to put my head around it but is it really impossible to make things truly 'random' in the programming world... i mean is there such a thing as random to begin with? like when ive told programmers to 'make it random'.... do you like instantly dismiss the idea of 'random' and come up with something that has enough breathing room to feel 'random' or is there a such thing as random... also i might have had some drinks today. but regardless, that has been on my mind. i think about stuff while i goto and come back from work and sit on the train for an hour.

MSG's got most of it down, but i'd like to add some technical mumbo jumbo I learned along my security travels.

so, Here's the thing about computers: They don't do random. You can tell a person to pick a number from 1 to 10, and they'll pick something that we would consider "random" - you tell a computer to spit out a number 100 times, and it'll be the same number over and over again. The essence of "random" is "unpredictable" - and computers are very, very bad at being unpredictable. They live in a world of math and logic. Unpredictability is quite literally impossible in that world.

Now, that isn't to say that you can't have seemingly-random numbers. This is called a pseudo-random number, and the generators that make them are pseudo-random number generator or PRNG. These generally deal in a number as a seed value, and use bitwise operations to create a new value from the seed. This is a very fast operation, but the same seed value will always result in the same output number (as is the case with all PRNGs, secure or not - the same input results in the same output - always)

an example of a PRNG is AS3:

private static var _fastSeed:uint = 1; public static function fast(seed:uint = 0):Number { return Math.abs(((seed) ? seed = (seed * 16807) % 2147483647 : _fastSeed = (_fastSeed * 16807) % 2147483647) / 2147483647); }

this returns a number between 0 and 1. The big issue is that it doesn't do any checks whatsoever, so the number could be (and has a high chance of being) something like 0.0000000000000000000000000000000000000000000000000000000000 000000000000000000000000000001348543564356432657865928374659 4386584365784365464326
which is pretty useless.

so, the big question is: How can you have a PRNG that is hard to guess? This is where a cryptographically secure random-number generator or CSPRNG comes in. An example is the Blum Blum Shub algorithm, which takes two prime numbers and a seed into account. As long as the seed is not known (this generally stems from a timestamp) it is almost impossible to predict. It has the unfortunate drawback of also being very slow, however, as re-calculations must be done every time a limit is reached (even then, there's quite a few steps to it)

Blum Blum Shub in AS3:

private static var _prime1:uint = 0; private static var _prime2:uint = 0; private static var _oldSecureSeed:uint = 2; private static var _sequence:Vector.<Number> = new Vector.<Number>; public static function secure(seed:uint = 0):Number { var M:Number; var xi:int = (seed > 1) ? seed : _secureSeed; var returnNum:Number; if (!_prime1 || !_prime2) { do { _prime1 = Math.random() * uint.MAX_VALUE; }while ((_prime1 - 3) % 4 != 0 || !isPrime(_prime1)); do { _prime2 = Math.random() * uint.MAX_VALUE; }while ((_prime2 - 3) % 4 != 0 || !isPrime(_prime2)); } M = _prime1 * _prime2; xi = (xi * xi) % M; if (_sequence.indexOf((xi * xi) % M) == -1) { _sequence.push(xi); }else { if (seed <= 1) { if (_oldSecureSeed == uint.MAX_VALUE) { _oldSecureSeed = 2; _prime1 = 0; _prime2 = 0; }else { _oldSecureSeed++; } _secureSeed = _oldSecureSeed; xi = _secureSeed; returnNum = secure(); if (returnNum) { return returnNum; } return 0; }else { seed = (seed == uint.MAX_VALUE) ? 2 : seed + 1; returnNum = secure(seed); if (returnNum) { return returnNum; } return 0; } } if (seed <= 1) { _secureSeed = xi; } if (_sequence[_sequence.length - 1] / uint.MAX_VALUE) { returnNum = Math.abs(_sequence[_sequence.length - 1] / uint.MAX_VALUE); return returnNum; } return 0; } private static function isPrime(val:uint):Boolean { if (val < 2) { return false; } if (!(val % 2) && val != 2) { return false; } for (var i:int = 3; i <= val / i; i += 2) { if (!(val % i)) { return false; } } return true; }

once again, however, this has a small chance of coming up with some ridiculously small number. I fixed all of this by adding a "normalize" function, which slows things down a bit, but will also return better-looking numbers.

here is the full class, if anyone wants it. It took me a few hours and quite a lot of google-fu to get everything working. (I suck at math)

The main reason I created the class is because I wanted random numbers that came out the same every time. It's nice for testing - means you can rule out the possibility of randomness when things go wrong.


Programming stuffs (tutorials and extras)

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

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-18 12:34:30


I did want to mention a certain website that spits out random everything, but I needed a shower this morning and ran out of time.

So, random.org is generally your go-to for random anything. It outputs cryptographically secure random whatever-you-need without being pseudo-random.
But how does it do this?

By the use of a special piece of hardware that measures fluctuations in air pressure. Yeah. Goddamn air pressure. I'm not sure exactly how they use this to their advantage, but i'm going to stab a guess at a linux OS and the /dev/urandum file. What I would do is simply unload the data from the hardware into memory and let linux's native random generator do the work for me (/dev/random and /dev/urandom take data from the OS - RAM, HDD, etc etc, and slap it all pseudo-randomly into a file which you can read from to grab ASCII characters - the difference between the two is /dev/random is blocking and /dev/urandom is not. Meaning random will give an "end of file" at some point, and urandom will create more as it needs more)


Programming stuffs (tutorials and extras)

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

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-18 14:50:59


At 2/18/13 01:19 AM, Luis wrote: That reminds me though... maybe im too artsy to put my head around it but is it really impossible to make things truly 'random' in the programming world... i mean is there such a thing as random to begin with?

Random doesn't really exist in the real world (ok quantum mechanics maybe), stuff just feels random cause of complicated functions with unpredictable inputs.

When we have quantum computers we will get "true random" stuff.

Response to The Flash 'Reg' Lounge 2013-02-18 14:58:32


At 2/17/13 01:13 PM, PrettyMuchBryce wrote: How are you guys doing Multiplayer in Unity ? Does it come built in with some sort of socket server ?

http://docs.unity3d.com/Documentation/ScriptReference/Networ k.html

its all built in to unity

you attach a NetworkView component to an object and it gets synced over the network, you can also call functions over the network too (they call them RPCs)

http://docs.unity3d.com/Documentation/ScriptReference/Master Server.html

this is how it does game lobbies, you need a server for it but unity has a master server available for development (its recommended to host your own for release cause theirs is unreliable)

Its super damn easy actually, except when you start getting into those weird network things like one player destroys a bomb while still receiving updates for it coming from a laggy player or whatever

Response to The Flash 'Reg' Lounge 2013-02-18 15:02:13


At 2/18/13 02:50 PM, Glaiel-Gamer wrote: Random doesn't really exist in the real world (ok quantum mechanics maybe), stuff just feels random cause of complicated functions with unpredictable inputs.

When we have quantum computers we will get "true random" stuff.

technically correct, but a defining factor in "random" is "unpredictability" - meaning a CSPRNG is random, as is real-world randomness.
For 99.99% of use-cases, pseudo-random numbers are random enough.

The thing about a PRNG is that is can be reverse-engineered to get the seed value by simply having the function. You could argue that by keeping the function secure you keep the seed secure, but that's detrimental to cryptography to a point beyond uselessness. Take a cryptographic algorithm designed to encrypt a string value; for example, the Rijndael block cypher (one I am very fond of, as it was previously crowned the king of encryption by AES - thus, the "AES standard" - i'm not sure if it still holds that title, but it's easy to use and is secure enough with a 128-bit key that i'm not worried in the slightest) - the Rijndael algorithm is open-source, yet to decipher the output you MUST have the key. There is no other way. This way, if another party gets ahold of the algorithm, it's still useless. Then you can freely distribute the algorithm without compromising any security.


Programming stuffs (tutorials and extras)

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

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-18 15:35:57


At 2/18/13 01:41 AM, MSGhero wrote: It's more along the lines of being "random enough."

Exactly. It's a question of whether a random generator is sufficiently "random" for the purpose.

At 2/18/13 12:34 PM, egg82 wrote: By the use of a special piece of hardware that measures fluctuations in air pressure.

That's pretty badass - I wonder if they have to make the environment as secure as possible to ensure that no one can set up tests to attempt to predict the air pressure.

Response to The Flash 'Reg' Lounge 2013-02-18 15:36:29


At 2/18/13 02:58 PM, Glaiel-Gamer wrote:
At 2/17/13 01:13 PM, PrettyMuchBryce wrote: How are you guys doing Multiplayer in Unity ? Does it come built in with some sort of socket server ?
http://docs.unity3d.com/Documentation/ScriptReference/Networ k.html

its all built in to unity

you attach a NetworkView component to an object and it gets synced over the network, you can also call functions over the network too (they call them RPCs)

http://docs.unity3d.com/Documentation/ScriptReference/Master Server.html

this is how it does game lobbies, you need a server for it but unity has a master server available for development (its recommended to host your own for release cause theirs is unreliable)

Its super damn easy actually, except when you start getting into those weird network things like one player destroys a bomb while still receiving updates for it coming from a laggy player or whatever

It is super easy to set up a lobby and a game with people running around. I could've never done it before now.
The big thing that tripped me up was that my game relies on swapping vehicles. If players spawn their own vehicles in then it causes a big problem when they leave, and swapping who owns what was a difficult thing to think about. I had to break out of the tutorials and examples given, but I think it's working fine now.

Response to The Flash 'Reg' Lounge 2013-02-18 15:41:54


At 2/18/13 03:02 PM, egg82 wrote: technically correct, but a defining factor in "random" is "unpredictability" - meaning a CSPRNG is random, as is real-world randomness.
For 99.99% of use-cases, pseudo-random numbers are random enough.

yeah I know I was just simplifying it a bit cause it was luis who asked

Interestingly enough, a fun fact, people are able to exploit the RNG in pokemon games to get whatever pokemon they want, by setting the system clock and timing a button press appropriately http://bulbapedia.bulbagarden.net/wiki/Pseudorandom_number_g eneration_in_Pok%C3%A9mon

also a lot of games don't like using plain random functions, cause it often feels unfair. (Missing a hit with a 90% chance to hit twice in a row just feels shitty, even if there's a decent chance that will happen a few times over the course of a game if you attack a lot)

IIRC fire emblem "stretches" out the displayed chance (so if it says 95% its actually closer to 99% and if it says 5% its closer to 1%)

Dota increases the chance of something happening every time it doesnt happen, so if you have say, a 25% to crit an attack, your first hit actually has an 8.5% chance, if no crit the chance rises to 17%, if still no crit its at 25%, if there's still no crit it goes up to 32%, etc, so averaged out over a lot of attacks the chance still is 25%, but you don't go long strings of attacks without getting a crit, or get a lot of crits in a row.

Response to The Flash 'Reg' Lounge 2013-02-18 15:54:38


At 2/18/13 03:41 PM, Glaiel-Gamer wrote: Dota increases the chance of something happening every time it doesnt happen, so if you have say, a 25% to crit an attack, your first hit actually has an 8.5% chance, if no crit the chance rises to 17%, if still no crit its at 25%, if there's still no crit it goes up to 32%, etc, so averaged out over a lot of attacks the chance still is 25%, but you don't go long strings of attacks without getting a crit, or get a lot of crits in a row.

Fuck, man. I had that like 3/4 typed out.

99% of the research I'm doing right now is waiting for the temperature of the sample to stabilize...at least I get money

Response to The Flash 'Reg' Lounge 2013-02-18 15:56:04


At 2/18/13 03:36 PM, I-smel wrote: It is super easy to set up a lobby and a game with people running around. I could've never done it before now.
The big thing that tripped me up was that my game relies on swapping vehicles. If players spawn their own vehicles in then it causes a big problem when they leave, and swapping who owns what was a difficult thing to think about. I had to break out of the tutorials and examples given, but I think it's working fine now.

Do you just delete the vehicle and make a new one when that happens? I'm thinking of letting people pick up bombs other people threw and that's what i'd have to do there.

Yeah though, I've tried networking stuff before, and always got hung up on it like ("what if the game goes out of sync???? what if one player doesn't see the same things as another???"), and kept trying to do things like delaying the input by the max ping so every player would receive the same commands at the same time and the game would be 100% deterministic and shit.

And then unity just gives no fucks about that, what its actually doing under the hood is super simple, its just each player sending info on where the objects they control are a bunch of times a second, and when other players receive those packets they move the objects / set the variables (/ call functions the server tells them to call), and its like... its that simple? and it works? I guess I was always over thinking it

Response to The Flash 'Reg' Lounge 2013-02-18 16:31:12


I tried deleting them and producing new ones, it kept coming out as being really obvious that that's what I was doing.

I have the first player Instantiate a garage full of vehicles and store them in the scene. Then whenever a new player enters, they grab one of the vehicles, and put it back in the garage when they leave. So the planes never Instantiate or Destroy.
Whichever player is driving sends his position co-ordinates to all the other players, and that's a variable that can change whenever. If nobody's driving, then default back to Player 1.

If Player 1 leaves then I guess all the vehicles fucking dissapear, but I'll fix that later.

Response to The Flash 'Reg' Lounge 2013-02-18 16:42:20


I just realised that was more confusing than it had to be.

Players come and go as they want in the game and the vehicles just carry on as normal, because they're all technically owned by Player 1. That's the main point.

Response to The Flash 'Reg' Lounge 2013-02-18 17:05:02


At 2/18/13 03:56 PM, Glaiel-Gamer wrote: its just each player sending info on where the objects they control are a bunch of times a second, and when other players receive those packets they move the objects / set the variables (/ call functions the server tells them to call), and its like... its that simple? and it works? I guess I was always over thinking it

I think you might run into some bigger problems with this at scale. For instance, if the server is not authoritative then it could lead to players exploiting the game. Also this doesn't sound particularly optimized. If you had 1000 players in a game then I wonder if you could run into latency problems, because you are not really optimizing your network traffic. I think what you're doing now makes a lot more sense then wasting time building your own architecture, though; for sure.

Response to The Flash 'Reg' Lounge 2013-02-18 17:14:49


At 2/18/13 05:05 PM, PrettyMuchBryce wrote:
At 2/18/13 03:56 PM, Glaiel-Gamer wrote: its just each player sending info on where the objects they control are a bunch of times a second, and when other players receive those packets they move the objects / set the variables (/ call functions the server tells them to call), and its like... its that simple? and it works? I guess I was always over thinking it
I think you might run into some bigger problems with this at scale. For instance, if the server is not authoritative then it could lead to players exploiting the game. Also this doesn't sound particularly optimized. If you had 1000 players in a game then I wonder if you could run into latency problems, because you are not really optimizing your network traffic. I think what you're doing now makes a lot more sense then wasting time building your own architecture, though; for sure.

this is how unity built in stuff works, and I'm perfectly away of the risks of people exploiting the game, and I know it'll probably end up widespread at least in public lobbies, but i'll give the host the ability to kick people or ban them, and cause the game isn't that competitive and I wont tie rewards into winning matches, I don't think it'll matter too much.

I can just make it so if a player gets -kickban'd from a few different host servers, they get marked as a cheater and can't join games that disallow cheaters

Response to The Flash 'Reg' Lounge 2013-02-18 18:33:02


At 2/18/13 05:14 PM, Glaiel-Gamer wrote: I can just make it so if a player gets -kickban'd from a few different host servers, they get marked as a cheater and can't join games that disallow cheaters

I think your head is in the right place. Fucking with networking would be premature optimization at this point anyways since you are still building, prototyping, seeing what works.

Response to The Flash 'Reg' Lounge 2013-02-20 00:18:46


This group project is just a bad game of Dota 2. Matchmaking puts a frat bro on my team who like 30 minutes ago sends the files I asked for 5 days ago. The other guy is helpful occasionally but overall hasn't really done anything. They always want to do group meetings and dick around the day before it's due instead of just fucking doing something. The report had been sitting in google docs for 3 days waiting for the files so I could finish it.

My friend says from tomorrow on, the class gets worse. It would be ok if we got to choose partners from here, but I have no idea what will actually happen.

Anyway, just cutscenes, music, and saving/loading and I'm finished this RPG.

Response to The Flash 'Reg' Lounge 2013-02-20 12:37:48


The Humble Bundle Mojam (Link)

This is a cool idea. Several indie game studios, including Mojang, have gotten together for a game jam to raise money for charity. It'd be really neat to see Newgrounds host something like this, but I'm not sure how exactly it would work. I know in the past that Tom has encouraged jammers to funnel ad revenue to charity accounts, but I don't think that option was very popular.

Thoughts?

Response to The Flash 'Reg' Lounge 2013-02-20 15:05:38


At 2/20/13 12:37 PM, Archawn wrote: The Humble Bundle Mojam (Link)

This is a cool idea. Several indie game studios, including Mojang, have gotten together for a game jam to raise money for charity. It'd be really neat to see Newgrounds host something like this, but I'm not sure how exactly it would work. I know in the past that Tom has encouraged jammers to funnel ad revenue to charity accounts, but I don't think that option was very popular.

Thoughts?

maybe in one of the jams, youre given a charity from a pool and you have to use that cause/whatever as the direction you base your game on?


None

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-20 17:17:35


At 2/20/13 03:05 PM, Luis wrote: maybe in one of the jams, youre given a charity from a pool and you have to use that cause/whatever as the direction you base your game on?

That would actually be really cool, though a single charity wouldn't get very much from one game (I don't think they care how much the donation is, though). Maybe have a pool of charities smaller than the number of teams? Or just split up the total across them all.

It could be geared toward the rest of the community as well: maybe donate a dollar (via NG store or something) and get some unlockable in the game. That'd be pushing the 2 day limit, and idk if the api has access to any store data. Plus getting the word out about different charities and stuff.

Response to The Flash 'Reg' Lounge 2013-02-20 18:31:13


At 2/20/13 06:16 PM, Mr-Shark wrote: Someone check this out and tell me how it runs, I purposely filled it with shit to see how slow some computers will run. Theres also a mushroom to eat which also needs to be ran it adds many filters.
http://www.newgrounds.com/projects/view/533118

Runs smoothly, no problems as far as I can tell.

But, wat

Response to The Flash 'Reg' Lounge 2013-02-20 19:25:38


At 2/20/13 12:37 PM, Archawn wrote: The Humble Bundle Mojam (Link)

I gave them everything I have


Programming stuffs (tutorials and extras)

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

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-21 00:46:45


I learned something today:
FlashDevelop puts some defaults into programs that simply need to die.

Example One:
in the default Main constructor, you see

if (stage) init(); else addEventListener(Event.ADDED_TO_STAGE, init);

this should simply be:

addEventListener(Event.ADDED_TO_STAGE, init);

because code run from the constructor isn't a good thing (hard to debug), and events break this flow.

Example Two:
the mobile device constructor contains

addEventListener(Event.DEACTIVATE, onDeactivate); private function onDeactivate(e:Event):void { NativeApplication.nativeApplication.exit(); }

or some such nonsense. This causes the application to exit (but not go away) when sent to the background, effectively pushing a big red reset button when you switch to another task (or minimize the application) for any reason whatsoever.

speaking of FD, a new version recently came out, accounting for SDK and FP updates, as well as improvements to mobile device support and other such things. Get it while it's hot!


Programming stuffs (tutorials and extras)

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

thank Skaren for the sig :P

BBS Signature

Response to The Flash 'Reg' Lounge 2013-02-21 07:46:25


Hai guys.

Notice anything NEW?

Response to The Flash 'Reg' Lounge 2013-02-21 07:56:09


At 2/21/13 07:46 AM, 4urentertainment wrote: Hai guys.

Notice anything NEW?

Grats!

Response to The Flash 'Reg' Lounge 2013-02-21 08:24:38


At 2/21/13 07:46 AM, 4urentertainment wrote: Hai guys.

Notice anything NEW?

You hit 3,984 posts?! CONGRATS!

The gold looks good on you, grats :D