Recent posts by skyboy on Kongregate

Flag Post

Topic: Game Programming / [JS] Prevent/Disable/Intercept Print Screen

Originally posted by Draco18s:

File-print is a non-issue, because the browser is locked down to not having an address or menu bar.

ctrl+p

though this is easily defeated by using CSS rules (there’s an option for print-only visibility; maybe screen-cap visibility-only) to make the page blank, or better yet, make the entire page #FF00FF when printed: a complete waste of ink

 
Flag Post

Topic: Game Programming / Learn AS3 instead of AS2.

Originally posted by BluePriest:

Easy start, and although it wont get you as far as youd need to be, it still starts you off.

starting with Brainfuck is easy too, and since the language is turing complete, any computable sequence can be computed with it: meaning you can make games every bit as complex as a modern console game thrown out by EA or some other giant. it just won’t be remotely easy because it’s also a turing tarpit: anything complex is made insanely difficult; like walking through a tarpit.

and learning any language makes learning any other language that uses the same syntax easier: AS3, Java, C, C++, Visual Basic, C#, whatever.

 
Flag Post

Topic: Game Programming / Fullscreen resolution

Originally posted by JohnnyBohnny:

Does scaling every pixel require the entire game to be in a bitmap?

no. just change the scale mode on stage to alter how vectors are rendered

 
Flag Post

Topic: Game Programming / Is it possible to "inherit" an interface from a type?

Originally posted by BrainStormer:

I have a strong opinion, and you’ll never convince me otherwise

well, that’s a stupid stance to have on anything.

 
Flag Post

Topic: Game Programming / Pathfinding with shafts/elevators

Originally posted by UnknownGuardian:

The green dots you labeled (thought not shown well in the picture) have roofs and ceilings. Every horizontal path has a roof and a ceiling unless a shaft passes through that tile. (aka you can pretend that there is an a layer of dirt between them)

if that’s the case, typical A* is sufficient; every time the AI tries to move to a tile, call that tile’s interact function which will return a status for what the AI can do immediately and accepts a call back; if there is no wait period, the interact function discards the callback and returns 0 or whatever, otherwise it returns some other value and calls the callback when the AI can move onto that tile (this allows queues and not having multiple entities using elevators that don’t/can’t exist)

 
Flag Post

Topic: Game Programming / Identical, but not equal

Originally posted by Draco18s:

(Hint: string comparison has to compare every character to the other string, even if it finds a non-match, it doesn’t exit. Nor does it exit if the strings are of different lengths)

which is good security practice to prevent timing attacks (figuring out a hash like a safe cracker listening for the tumblers to click into position)

Originally posted by Draco18s:

++i and —i are slightly faster than their counterparts. But it’s on the order of 1 ms every million calls.

(Has to do with the fact that i++ and i— return their value twice, effectively: once before the increment/decrement which is what the expression evaluates to, and once after the increment/decrement, which is what the variable is equal to after the expression evaluates).

they perform identically: same operations in a different order

i++    | ++i
getloc | getloc
dup    | inc
inc    | dup
setloc | setloc

though if you have it in a statement by itself (not assigning it to a variable/indexing/in a comparison/etc.) they compile to exactly the same code: getloc inc setloc

Originally posted by oscarwilld:

It’s just a stylistic choice, but personally I find this more readable than a backwards loop:

var length:int = array.length;
for (var i:int = 0; i < length; ++i)
{

}

it’s just a stylistic choice on modern computers (usually1), but on older computers iterating forward is faster than iterating backwards because prefetching doesn’t work when looping backwards meaning the CPU is waiting for data to come in from RAM

1 though when flash is interpreted instead of compiled (at runtime), prefetching benefits for looping backwards are fully negated by nested looping tripping up the CPU, making forward looping once again faster


the fastest i can think of for your ints (use a Vector, too!) would be:

public function comp(a:Array, b:Array):Boolean {
	var i:int = a.length;
	if (i !== b.length)
		return false;

	var e:int = i, r:int = 1;
	for (i = 0; int(i !== e) & r; ++i)
		r = a[i] === b[i];

	return Boolean(r);
}
 
Flag Post

Topic: Game Programming / Is it possible to "inherit" an interface from a type?

Originally posted by Draco18s:

True, it isn’t, but the whole…factory design thing boggles my mind.

i’m pretty sure it came about when people began using complex objects in pools; good intentions gone corporate: they needed a way to reset all the variables and return the clean object, an instance method would work but looks ugly so static methods were used and it just got corrupted and simplified and compartmentalized from there until a CEO would look at it and say “so, can you make it bigger?” (basically, it’s an ongoing process)

 
Flag Post

Topic: Game Programming / (AS3) Changing quality with keyboard

there’s an edit button, and you need to read the stickies. Proper Forum Code Formatting Guide

 
Flag Post

Topic: Game Programming / Vector problem

Originally posted by Arloistale:

But isn’t using elapsedTime supposed to solve this kind of problem where timing is inaccurate because of lag? What is the best way to stay consistent then? Using frame based in the past always made timing inaccurate

inaccurate against real time, yes; but if your game requires active input (it’s not turn-based) then lag will cause things to move faster with less reaction time: input only occurs once per frame.

Originally posted by Arloistale:

Skyboy, if this method is absurdly slow, then what is a faster method? Cos / sin calculations? I used time based movement for better accuracy, since I’ve found frames to be very inaccurate. I don’t understand why you are giving me criticism without telling me why it should be criticized…

instead of even using your vector class at all, inline everything and use a regular point: Math.<x> is slow because it’s a static call; hiding that behind another static call doubles your overhead. creating new objects all other place you don’t use consumes substantial time, hiding a fast operation (like subtraction) behind a function call and a static look up is one of the worst slowdowns: well over 30x slower. Point itself isn’t too fast either because x/y are getters. there are a dozen other things in the code you’ve posted

 
Flag Post

Topic: Game Programming / Buying Browser Game (+)

Originally posted by Drakim:

Wait, does he want to buy the software for a MMO browser game, or an running instance of an MMO game with these specifications (including server)?

This is really confusing. I guess we will never know, since he won’t read this.

he’s also prevented anyone who doesn’t use skype (read: more than 3/4ths of the people on the internet) from ever contacting him by using skype instead of email!

Originally posted by UnknownGuardian:

I’m not certain what forum this belongs in. Unfortunately you don’t read forums so I guess we can’t ask you. :/

this belongs in the “deleted and burnt” section, when he can learn to read forums and make proper requests he can make a new post. when he’s turned 18 instead of 13 would also be a nice move.

 
Flag Post

Topic: Game Programming / Vector problem

Originally posted by Arloistale:

Yes, the elapsedTime is measured in seconds as I assumed you would be smart enough to understand.

why would we know it’s in seconds? it could be milliseconds or nanoseconds, days, hours, minutes or even tens of billions of years

also, your algorithm is absurdly slow: it looks like you’re intentionally choosing the slowest way possible to write code, then screwing over anyone with an older computer by using time-based physics instead of frame-based (equal to assuming the time between frames is always 33ms). do you work for zynga? they make things absurdly slow too

 
Flag Post

Topic: Game Programming / Need help with several problems(such as enemy clipping and loading movieclips into an array)

Originally posted by UnknownGuardian:

Count 1 skyboy. :D I’ll edit the Proper Code Formatting in. Then I’ll see if I can help.

unsticking it isn’t going to help any; an HTML popup (that is: not using window.open()) when people first load the page (saved as a cookie) would help stop the threads asking how to make a game and point them at how to format their posts

i pointed out that the problem is mostly from people who don’t have much experience on forums: new programmers, and particularly new flash programmers

 
Flag Post

Topic: Game Programming / Yay or Nay: Changes to Programming Forum stickies

Originally posted by Phoenix00017:

That might make sense Bob, but I don’t think it’s “new” as we haven’t changed that since probably 2006. UG might be right, but I don’t think it would make sense to add a formatting guide to the community page.

i’d meant this:

Originally posted by UnknownGuardian:

It could be “new” as in “create a new thread”. I can see how Bob got that page.

the link and title are for creating a new thread on the forum; rather than it being a new page itself. i couldn’t think of a better way to describe the page for creating a new thread than as the new thread page.

one possibility would be to reuse the little black box we get when posting on a thread for posting a new topic too; it’s simple, but it looks nice!

 
Flag Post

Topic: Game Programming / Keyboards...

Originally posted by SWATLLAMA:

Those two keyboards aren’t very similar. The Blackwidow is a mechanical keyboard, whereas the Deathstalker is just a regular rubber one. If Skyboy used it, he’d wear it out in less than a year.

i feel like the forum yardstick for “extreme use case”

 
Flag Post

Topic: Game Programming / Arrays and SharedObjects

also, generic deep copy that’ll work on nearly everything non-displaylist (though some special boilerplate is needed for custom objects/clases); and can copy as deep as is necessary

function reallyDeepCopy(data:*):* {
    var q:ByteArray = new ByteArray;
    q.writeObject(data);
    q.position = 0;
    return q.readObject();
}
 
Flag Post

Topic: Game Programming / Strange result drawing 1000 black lines.

Originally posted by Senekis93:

As a comparison, 100,000 particles run at a constant 30 fps.

particles are in AS3, his flashlight is in AS2 — this is one of those things that AS2 can’t match AS3 on

 
Flag Post

Topic: Game Programming / Keyboards...

Originally posted by jerimo:

The built in keyboard of my laptop (Asus, if it changes anything?)

BTW, I must ask, how did you all count the number of keystrokes on your keyboards?

programs that count the number of keys you’ve pressed over what time period; allowing you to graph the most used keys (hint: it’s space), i have a few years of data and can extrapolate out to the years i don’t have hard data

 
Flag Post

Topic: Game Programming / Despawning MC's in AS2.0

Originally posted by JohnnyBohnny:

I use AS2 because there are multiple ways to do something, you don’t have to clarify everything and because you can assign Math.sqrt("omg cats!")/[asdf, "asdf", int(asdf)] to _root._x. With AS2 I can be more creative and productive, even though the fps isn’t 60 but 40. If the fps does get too low, I can optimise some stuff, and it’s (semi-)fixed.
I have become skilled enough in AS2 to write code fluently without thinking too much about it, which is also the reason that I find it more difficult to learn AS3 than any other language: I am doing pretty much the same, but I have to look up things often, clarify everything, deal with multiple files(classes), and in the end, I created something in 60 minutes which I could have made in 10 minutes, and that is not very satisfying. (I am not saying that as2 is 6x faster)

And btw, you can actually create realtime multiplayer games using xml and php sockets with AS2 (besides creating the sockets themselves).

AS2 doesn’t have int()

AS3 doesn’t let you do insanely stupid things (like dividing by an array) because its insanely stupid; and complaining about errors being thrown is absolutely absurd: errors are your friends, they let you know when something is wrong. AS2 may seem better because it just swallows the errors and ignores the fact something’s wrong, but it’s hurting you in the end by making debugging more difficult and allowing you to do something (like access an undefined variable, and perform math with it) that you didn’t want to do because you made a typo and then promptly hides that fact

and not learning something new because your first steps are unsatisfying is rather childish: that’s like refusing to ever play in the snow because your first steps in it were cold

 
Flag Post

Topic: Game Programming / Strange result drawing 1000 black lines.

Originally posted by JohnnyBohnny:

Are you actually able to move the character and sliders and stuff, or did the freeze protection actually do the exact opposite? Because that would be pretty bad.

the “freeze protection” only means no one can even see what it looks like for very long. however you’re doing it is just sloppy at best, and so horribly inefficient i haven’t actually seen what it produces; mostly because you kill it after 3 seconds, limit is usually 15 seconds before flash steps in and kills it — i’ve upped that on my computer to 60 due to the performance tests i run. but an unresponsive flash app i can manage. a flash app that self-terminates so i don’t get the chance to see it or manage the unresponsiveness is just stupid

and what good would refreshing do? make the user experience the same crap again with no chance of it ever improving because you don’t make any effort to make it cheaper when you detect lag, you just flat out kill it and make it impossible to modify

 
Flag Post

Topic: Game Programming / Strange result drawing 1000 black lines.

Originally posted by JohnnyBohnny:

Here is something similar:

Link

that’s shit-tastic. forcing you to reload the page if rendering takes too long and refusing to render it further is the dumbest thing i have ever seen.

 
Flag Post

Topic: Game Programming / Keyboards...

Originally posted by DPbrad:

EDIT: Must have easily been over 100mil key presses. It was used daily for around 14 years.

i average around 1 million keys every month and a half, most of it is from programming and chatting with friends

 
Flag Post

Topic: Game Programming / Yay or Nay: Changes to Programming Forum stickies

Originally posted by UnknownGuardian:

Well I don’t mind leaving that thread up but I think the amount of people that show up without pre tags is going to be the same as if it was taken down, or very close.

I also wouldn’t mind doing a test for like a month to see if its absence makes a lot of un-formatted code show up.

it helps the people who want help, instead of the people that just want us to “give [them] the codes” to make it work

 
Flag Post

Topic: Game Programming / Keyboard double click

Originally posted by Senekis93:

Also, using getTimer would be better. Lag can mess with any frame based system (not that the other method is perfect, but it’s surely more reliable).

not really: you won’t get two key events in the same frame, and you certainly won’t get them while something else is being processed (graphics, code, whatever) in a single-threaded environment.

the frame counter is most reliable: giving a larger delay is better than making the window not exist due to severe lag

Originally posted by JohnnyBohnny:

In this case, if a key is hold down, it will reset it to 0. The next frame, timeSince++, it becomes 1. It goes through the if statement I just gave, and timeSince !> 1, so it is not a double key press.

If a key is released, the ‘timer’ will start at one, as explained before, and keep adding 1, without resetting it, so it will be > 1. If the double key presser is fast enough, and presses the same key before the ‘timer’ reaches the limit (5 in this case), all statements in the if are true.

your code won’t work and your idea won’t work reliably.


some generic code:

counter:int, key:int
checkKey(code) {
if (code != key) counter = 0;
key = code;
}
onKeyDown(e) {
code = e.keyCode;
checkKey(code);
if (counter != 2) counter = 1, timer = limit;
onPress(code);
}
onKeyUp {
checkKey(code);
if (counter && timer && ++counter == 3) onDoubleTap(code);
onUp(code);
}
onEnterFrame {
if (timer) --timer;
}
 
Flag Post

Topic: Game Programming / Keyboards...

a very durable HP mechanical keyboard that was bundled with my computer when it was bought, 10 years ago. it’s had soda spilled on it many times, and still functions; on top of having about 75 million total keystrokes. the “e” “s” “a” “d” “w” “o” “r” “m” and “n” keys have all been rubbed off; leaving an indentation. best i can tell it doesn’t even have a name, let alone something that’d sound cool like “sidewinder”

i’d say the keyboard is worth more than the computer that came bundled with it (for free, even!) based on the amount of punishment it’s been delt and how well its stood up

 
Flag Post

Topic: Game Programming / Yay or Nay: Changes to Programming Forum stickies

Originally posted by UnknownGuardian:

Maybe. I’m willing to bet that a majority of posters don’t check that before posting. I would think that a lot of new comers glaze over the stickies like they aren’t there. And if I see someone posted code without the formatting I usually fix it up for them.

yes, but for those few who have sense enough to read obviously important things relevant to what they’re doing (they exist! they just don’t exist in mass on kong or in the flash development cliques because it’s easy) it is very helpful. hiding it under something that would strike as common sense (rules/conduct/telling you not to be a jackass/etc.) like the proposed “how to use the forum” thread, it’s going to get skipped by everyone; even i’d skip something with a title like that, mostly because of how long i’ve used forums (i still haven’t really read the CoC/ToS)

the thread, as it is now, tells people who read the title that this forum works differently, and bbcode/etc. they’re used to probably won’t work. if they read the title and skip it, then saw the formatting help thing (Phoenix – that honestly should be on the new thread page; which looks like crap, btw) they’d realize that this isn’t what they’re used to and go back to read it