Recent posts by Jabor on Kongregate

Flag Post

Topic: Game Programming / [Decided too complex to implment closed]Difficult Geometric Sorting/Search Algorithm

Ignoring lines which are exactly aligned with the player … (which don’t cast shadows anyway, so it’s safe to ignore them):

1. Work out the angle of each endpoint relative to the player.
2. For each line segment, tag the endpoint with the lowest angle as the “start”, and the endpoint with the highest angle as the “end”.
3. Sort the endpoints by their angle.

Then you can loop through all your points of interest. When you see a “start” point:

1. Remember that that line segment is currently active.
2. If that endpoint is in front of the existing frontmost line segment, that endpoint marks where a shadow starts, and that line segment is now the frontmost one.

When you see an “end” endpoint:

1. Remember that the corresponding line segment is not active any more.
2. If that was the frontmost line segment, that endpoint marks where a shadow ends, and look at the other active line segments to figure out which one is now the frontmost.

Note that this assumes line segments don’t overlap – if they do, though, you can just break them into four separate line segments that happen to have the same endpoint and things should just work.

 
Flag Post

Topic: Game Programming / Unity discontinues Flash support

Where might they be getting the data of migration away from flash? Or little traction when it occupies 98% of computers. I would agree that their platform has some good growth and they should focus strongly on getting their platform out there.

I just wanted to chime in here, because ultimately developers are moving away from Flash as a platform. The desktop market share is irrelevant at this point (it’s actually falling quite noticeably as HTML5 video improves, but that’s not really relevant) – for casual games the mobile market is where the money is. Unity is far better than Flash for mobile games, and the Unity plugin also beats the pants off Flash Player for the sort of games you don’t want to play on mobile. Flash doesn’t really have a niche left.

Flash as a technology has essentially run its course. It will stumble on for a few more years on its prior momentum, but any company would be foolish to make a big bet on it at this point.

 
Flag Post

Topic: Game Programming / Flash Being Deprecated?!?! Wasup with this rumor?

Claiming that Flash is faster than a PS3 is pretty dumb, to be honest. Flash isn’t a piece of hardware, how fast it is depends on what its running on. Trying to claim that as a measure of “power” is even sillier.

In terms of stability, I honestly don’t know how anyone can claim that Flash is more stable than a modern browser. Flash is a gaping security hole that browser developers have been trying to bandaid over for years. It’s trivial to exploit Flash. Exploiting a browser without using flash is much harder.

 
Flag Post

Topic: Game Programming / web developing

Plugins in general have major accessibility problems. Mixing plugin and HTML content really messes up screen readers and other accessibility tools, and trying to use them with Flash in particular is an exercise in frustration.

In the web as it stands today, Flash is only useful for multimedia content, and even then only for legacy browsers or where HTML5 hasn’t stabilized yet. This is not me saying “lol flash sux”, this is a fact.

If you’re going to learn Flash, learn it to make Flash games. If you want to do web development in general, Flash is not particularly useful.

 
Flag Post

Topic: Game Programming / web developing

No-one makes static websites any more. Even for a set-it-up-and-forget-about-it website, getting a CMS set up and themed is just so easy that hand-building a static website is a waste of time.

Flash websites are well and truly dead (and good riddance). And outside of games, you only ever use flash as a legacy media player. And even those are (slowly) dying off. If you you’re just learning, and you want to be a web programmer, you need to be good with HTML and CSS.

 
Flag Post

Topic: Game Programming / If there were 3 programmers working on the same as3 project

Look into a revision control system. Ideally you’d be using something like git to help with integrating your work and all that, which gives you the ability to get useful diffs essentially for free.

 
Flag Post

Topic: Game Programming / I Have No Idea How To Go About This

What you really want is a connected-components analysis. Flood-filling is one way of doing this, but is going to be horribly slow.

The easiest way is basically to use a two-pass algorithm. You’re going to assign each point in the grid to a region based on what it’s connected to.

Start by checking the value of the point to the left of the current point, as well as the value of the point above the current point.

  • If neither of those points matches the current one, assign the current point to a new region.
  • If only one of those points matches the current one, or both match and have the same region number, assign the current point to that region.
  • If both points match but belong to different regions, assign the current point to one of those regions and then record that those two regions are equivalent.

That’s the first pass. The second pass consists of going through the points again, normalizing all the equivalent regions so that they all have the same value. This may not be necessary depending on how you’re going to use the results.

 
Flag Post

Topic: Game Programming / How Others Do It #1

sortByDistance :: Point -> [Point] -> [Point]
sortByDistance (x0,y0) = sortBy (compare `on` \(x,y) -> (x-x0)^2 * (y-y0)^2)

Haskell I know, but I do think the functional style is clearer here.

 
Flag Post

Topic: Game Programming / problems with Brick Breaker Help AS3

Because of the way your braces are set up :)

Don’t just mindlessly put them in to shut up the compiler. Take your time, go through, and make sure each close brace matches up with an open one.

 
Flag Post

Topic: Game Programming / problems with Brick Breaker Help AS3

The computer is dumb. If it points a “syntax error”, don’t blindly think it’s right and comment it out. Think about it a little.

Secondly, it’s really hard to see what’s wrong with all those comments cluttering things up. Post your code (all of it!), and then post (separately!) what goes wrong when you try to compile it.

 
Flag Post

Topic: Game Programming / Code inside HTML

Use &lt; and &gt; entities instead of < and > in your example code.

 
Flag Post

Topic: Game Programming / Feasibility of Doomlike "3D" Flash FPS

Anything bigger gets laggy.

Sounds like you need some optimization :)

The original Doom engine used binary space partitioning to basically limit the amount of stuff being drawn to just what was visible.

 
Flag Post

Topic: Game Programming / Disabling Cross Domain Policy Thing (JavaScript, Firefox) [SOLVED! Hopefully]

Originally posted by Draco18s:

Welcome to cross domain policy. The security feature that prevents exactly what you’re doing unless the target site lets you.

No, you can’t disable it

Sure you can. You just need to get the user’s permission in order to disable it for your application. How?

Remember that extensions and plugins are allowed to ignore the same-origin policy.

 
Flag Post

Topic: Game Programming / Disabling Cross Domain Policy Thing (JavaScript, Firefox) [SOLVED! Hopefully]

Yes, I know what I’m doing.

Well, what are you doing?

Is there a specific application you’re working on that to needs perform cross-origin requests? Do you control the target machine? Does this need to run on machines other than your own?

You might know what you’re doing, but until we know more specific details, it’s hard for us to find a solution to your actual problem.

 
Flag Post

Topic: Game Programming / [AS3] Using variables from other classes

wherein you have some variables that make your objects move or roatate.

This is unclear. I presume you have a variable holding a number, and your enter frame event checks the value and uses it to move/rotate stuff?

The question is: how to access those values?

If you have one value that you want shared across all instances of a class, you make it static. If you also make it public, you can access it from anywhere.

So you want something like:

in main class:
public static var rotationRate = 5;

elsewhere:
rotation += MainClass.rotationRate;
 
Flag Post

Topic: Game Programming / Html5 and mobile devices

natively outputting HTML input as display data,

The fact is that it’s more efficient to parse and render HTML in software. A spec-conformant hardware implementation would cost more than a general-purpose processor that can render just as fast – especially with more recent advancements with GPU-accelerated rendering and the like.

Even if the HTML spec were static and unchanging, this would still be the case.

 
Flag Post

Topic: Game Programming / Html5 and mobile devices

you can’t hardware parse HTML/JavaScript;

I’m not entirely sure what you mean by “hardware parse”. A software parser by definition just tells a piece of hardware how to parse something.

What I think WTF_CowBoY is referring to is the fact that a lot of recent ARM processors are capable of natively executing JVM bytecode, whereas similar support for Adobe’s virtual machine is unlikely to happen. As well as the fact that hardware acceleration of Javascript and HTML rendering is getting a lot of focus these days, while Flash Player is still slow by comparison.

 
Flag Post

Topic: Game Programming / error 1009, help...!

Have you actually placed areaOver on the stage in frame 1?

 
Flag Post

Topic: Game Programming / A cool sort I made

both O(N² log N) and O(N³).

In fact, all functions in O(N² log N) are also in O(N³). And O(N4). And so on up.

It is more useful to state the lowest upper bound, though.

 
Flag Post

Topic: Game Programming / Inheriting variables?

It made the fire invisible, but that should be easy to fix.

Chances are it’s not invisible, just off screen.

Instead of setting the position of the fire to the position of the character, just set it to (0, 0), and see where it ends up.

 
Flag Post

Topic: Game Programming / error 1009, help...!

what do u mean?

Alright, Jabor’s quick n’ dirty introduction to variables coming up…

Suppose you have a box. This box is designed to hold a single photograph at a time. You want to do something to the photograph inside the box, but when you open it up, the box is empty. Nothing in it.

That’s basically what’s happening here. Your code wants to add an event listener to what’s inside the box, so it opens up the areaOver box and … it’s empty. Nothing in it.

how can i fix it?

Put something in the box.

areaOver = ...

 
Flag Post

Topic: Game Programming / Inheriting variables?

Basically just replace all the _roots in that line with the instance name of your character movieclip.

 
Flag Post

Topic: Game Programming / error 1009, help...!

areaOver.addEventListener(MouseEvent.MOUSE_OVER, aOver);

areaOver is null.

 
Flag Post

Topic: Game Programming / Inheriting variables?

…which I want to move with the character.

Then what you really want to do is attach it to the character’s movieclip, rather than to the stage.

 
Flag Post

Topic: Game Programming / A cool sort I made

i’m not sure how much optimizing the flash compiler does but I would expect there should be some optimizing for recursion to get rid of the function call overhead…

It might optimize tail recursion, but it’s unlikely to unroll recursive functions onto their own stack. I’m not aware of any mainstream compiler that uses an internal stack instead of the system one for recursive function calls.