Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
Code inside HTML
Use < and > entities instead of < and > in your example code.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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;
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
error 1009, help...!
Have you actually placed areaOver on the stage in frame 1?
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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 = ...
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
Inheriting variables?
Basically just replace all the _roots in that line with the instance name of your character movieclip.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
error 1009, help...!
areaOver.addEventListener(MouseEvent.MOUSE_OVER, aOver);
areaOver is null.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
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.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
Code Optimization
If an event never fires, having event handlers attached to it doesn’t waste any time at all.
Adding and removing event handlers takes longer than that, so not worth it.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
A cool sort I made
What about flood fill, jon. That should easily reach that deep.
A flood-fill algorithm, in the worst case (filling an entire image from one corner) will only go as deep as the width + the height of the image (for a 4-way fill).
If you’re doing it on an image the size of the screen (800×600 or something) then you’ll hit that, but if you’re just filling a single sprite or something you’re fine.
Of course, if you’re worried about hitting the recursion limit you can instead implement it iteratively and manage the stack yourself.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
A cool sort I made
flash has a limit on function recursion;
By default, 256 nested calls.
Arrays in Flash can only have 231 items. Which will take 31 levels of recursion to sort. Nowhere near blowing the stack.
if flash’s reference count mess up, then it will remain in memory for an unnecessary amount of time.
“If there’s a bug in Flash Player, this code won’t work” is hardly an argument against it. The temporary arrays are eligible for collection immediately when they go out of scope or are replaced by other arrays – the only reason they wouldn’t be collected is if there’s no memory pressure and thus no need for them to be collected right now.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
A cool sort I made
That is a mergesort implementation.
and if flash’s GC works correctly, the additional memory is only temporarily required
I’m not sure how one would create a sorting algorithm that permanently occupied memory even after it had finished sorting.
The point is that this requires allocating additional memory, while quicksort can be done in-place, without any additional allocations.
and there’s potential for recursion problems (limits) to arise.
You’ll only get problems with blowing the stack if you’re sorting more than ~1075 items. If that’s the case, I don’t think stack limits are going to be your biggest problem.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
A cool sort I made
Quicksort is potentially quadratic, so is possibly worse than mergesort (though quicksort can be done in-place, while mergesort requires additional memory).
Quick mergesort implementation (untested, of course).
public function mergeSort(a:Array):Array {
if(a.length <= 1) return a;
var l:Array = a.splice(0, a.length / 2);
l = mergeSort(l);
a = mergeSort(a);
var i:int = 0;
var j:int = 0;
var k:int = 0;
var r:Array = new Array(l.length + a.length);
while(i < l.length || j < a.length) {
if(l[i] < a[j])
r[k++] = l[i++];
else
r[k++] = a[j++];
}
return r;
}
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
Code Jam Round 1
I just think that using a language designed purely for golfing (or, in fact, designing a language purely for golfing in the first place) kind of misses the point of what golfing is about. But feh, that’s just my opinion.
50 characters if you count the -n, using -e/-E is a zero-character change.
The code does produce correct output when given only the relevant part of the input.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
Tower Defense Path points
If they move on a fixed path, it might be better to just store a series of points indicating the corners – when they reach one of those points, they start moving in a straight line towards the next, until they get to the last one.
|
|
|
Jabor
11382 posts
|
Topic: Game Programming /
Code Jam Round 1
Since I consider using a language designed for golfing to be cheating:
perl -nE 'split;say"Case $.: O",($_[1]+1)%2**$_[0]?"FF":"N"'
49 characters, in a language designed for practical use rather than for golfing.
|