someone93
261 posts
|
Topic: Game Programming /
Google Code Jam 2013
I decided to join in and solved the first two problems in the only language I had at hand, C++ (which a don’t even now that well). I would have used C#, but I didn’t fancy downloading mono and a mono IDE just for that…
Mad props to you guys who actually solved each problem in a different language. It’s quite impressive. I considered trying #2 in befunge, but I never got around to it.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
Basic math question
You would need at at least one angle to be able to calculate the third side. If you know an angle, you can use the law of sines and the law of cosines to get the information you need. If you know the coordinates, then some vector math would be a good choice.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
My Little Pony
Totally wrong forum. This should be in the Off-topic section. Hopefully a moderator can move it there.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
AS3, this elastic collision calculation for circles doesn't work
Originally posted by ErlendHL:
Edit: What is zmf?
Zero momentum frame, mentioned in his first point.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
How to use preloader
Originally posted by Arloistale:
If I have many levels, like say 60 or so, won’t it look cluttered to embed them all? Is there a way I can load multiple xmls without it looking like a huge wall of text?
What about creating bundles of levels? XML would be perfect for that kind of stuff.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
PGGC #3: Planet
Originally posted by RTL_Shadow:
Originally posted by Elyzius:
After studying the object with a spectrum analyzer, scientists at NASA have concluded that it is a dick.
Heh. Don’t judge me- i was bored.
I agree, cut him some slack. We don’t need to be a dick about all this, do we?
|
|
|
someone93
261 posts
|
Topic: Game Programming /
A* with NO diagonals
Ah, I read the topic more closely now. You mean diagonal as in one step north then one step east, rather than one step north-east? My bad for missing that.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
A* with NO diagonals
Just increasing the cost wouldn’t work if you add walls.
Something like the below would return a path, which you wouldn’t want.
S..X
..X.
-X..
X..G
S = start, G = goal, .=walkable, X = wall
Can’t you just skip checking diagonal neighbours (like mentioned above)?
|
|
|
someone93
261 posts
|
Topic: Game Programming /
are there more multiples of 3 or 7?
Originally posted by BigJM:
It is unable to be determined; therefore, it is indeterminate.
Heh, I guess I wasn’t as sure about translation of mathematical terms as I thoughts. To me, 1/0 would be “undefined” and 0/0 would be “not well-defined”. I guess I’m just handicapped from learning math in my native tongue.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
are there more multiples of 3 or 7?
Originally posted by BigJM:
x/0 is not infinity, it’s indeterminate and contextual.
x/0 = a (or a*0 = x), for x != 0, is undefined, not indeterminate. There is not a single solution.
0/0 = a (or a*0 = 0) on the other hand is indeterminate. There is not a unique solution (it’s true for every value of a).
|
|
|
someone93
261 posts
|
Topic: Game Programming /
are there more multiples of 3 or 7?
I can’t remember specifics. But we showed it in my Uni. intro math.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
are there more multiples of 3 or 7?
Originally posted by ErlendHL:
What’s infinity / infinity?
This is one of the cases where we can’t really say anything.
Other such cases include:
0*inf, 1^inf, inf – inf
|
|
|
someone93
261 posts
|
Topic: Game Programming /
web developing
Originally posted by qwerber:
Originally posted by someone93:
Originally posted by qwerber:
HTML5 is open and free. Everyone can access. And it is browser native.
How is this a good thing?
I see Flash becoming java lol.
Except Java is cross-platform (which can’t be said about flash anymore, since Adobe dropped development for Linux).
Linux still has chrome flash support. AHA.
Sure, but that means Chrome is the only program with an up-to-date flash player. And to make things even worse, the version Adobe left Linux with has hardware acceleration disabled (which makes my processor overheat if I run fullscreen flash videos).
|
|
|
someone93
261 posts
|
Topic: Game Programming /
web developing
Originally posted by qwerber:
HTML5 is open and free. Everyone can access. And it is browser native.
How is this a good thing?
I see Flash becoming java lol.
Except Java is cross-platform (which can’t be said about flash anymore, since Adobe dropped development for Linux).
|
|
|
someone93
261 posts
|
Topic: Game Programming /
AS3-Move Direction Ship is Pointing (Felt Like An idiot, compliments to skyboy)
Originally posted by CuriousGaming:
Originally posted by BigJM:
You actually want to do rotation*Math.PI/180
Damnit. I always get those the wrong way round.
An easy way of telling is to look at the units.
Math.PI/180 is radians per degree, which is what you want to convert to radians.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
[C++] Quick question about infinite for-loop
That would mean pretty much, inititialize nothing, check nothing (missing boolean defaults to true in for loops) and increment nothing.
for(A;B;C) {
D();
}
// Would be equivalent to:
A;
while(B) {
D();
C;
}
// With the only difference that a missing B dafaults to true in a for loop.
E.g.
for(;;) {
foo();
}
// Is equivalent to:
while(true) {
foo();
}
|
|
|
someone93
261 posts
|
Topic: Game Programming /
Highlighting hex grid using A* need help
Another way to do this would be to use the Floyd–Warshall algorithm once to find all shortest paths from any point to another. And then just look up values.
But I guess this is only feasible as long as the weights don’t update often. If they were to be updated you would have to redo the computation for every update.
Edit: Actually, BFS until you reach the given cost limit would probably be the most intuitive way to do it.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
move to next frame when my character hits an object?
So, what about just checking if the hitTest triggers? Then it would be obvious where the problem is.
Does unloading the movieclip prevent further code from executing? If so, that would explain things.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
move to next frame when my character hits an object?
Originally posted by Draco18s:
Someone doesn’t know how to use the pre tag properly. Forgot the blank lines.
Also, it should be fairly obvious that that code is on mic_mc.
Yeesh, give me a break. I just haven’t posted code for a while.
And yeah, it should be obvious. But I’ve seen people hit testing an object on itself before. Though I guess a hit test on the object itself would be true?
And when I said “make sense”, I meant that it would make sense to check if the player hits something rather than the opposite.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
move to next frame when my character hits an object?
Where is this code? Is it under char or mic_mc?
If it’s under char, which would make sense, then
this.hitTest(_root.char)
should be
this.hitTest(_root.mic_mc)
Otherwise, try putting some trace statements and check if the enterFrame is running properly. And if so, check when the hitTest is triggering.
|
|
|
someone93
261 posts
|
Topic: Game Programming /
consecutive 4 digit integers problem.
2010² = 2*2*3*3*5*5*67*67
If the 67’s isn’t found in the same number, then X>=68 (modular arithmetic).
If they are:
67*67 = 4489 < 10,000
Let’s observe the following sequence:
{4485, 4486, 4487, 4488, 4489. 4490}
We have two factors of 67 (in 4489)
We have two factors of 5 (in 4485 and 4490)
We also have the needed factors of 2 and 3.
So we can conclude that X<=6.
(The above sequence is the minimum length sequence around 4489)
What could we do to improve this?
The 5s are the key here, if we want a smaller sequence, 5*5=25 must be in one of the factors.
We know that 67*67 must be in one of the factors, and the only other case (for a factor < 10,000) is 2*67*67 = 8978.
Is there any factors of 25 around 8978?
Yes! 8975 is such a factor.
Let’s observe this new sequence:
{8975, 8976, 8977, 8978}
We have two factors of 67 (in 8978)
We have two factors of 5 (in 8975)
We have more than enough factors of 2, but what about 3?
Only 8976 is divisible by 3.
So, let’s append 8979 to the sequence.
This gives us X<=5.
But we can do no more optimizations, so the answer is X = 5.
Edit: I knew someone would get in there before me, but I didn’t care to refresh the page. :P
|
|
|
someone93
261 posts
|
|
|
|
someone93
261 posts
|
Topic: Game Programming /
Solved, AS3 - fast way to implement simple 90 degrees rotation?
var _y:uint = 0;
var _x:uint = 0;
for (var y:uint = 0; y < 20; y++) {
for (var x:uint = 0; x < 20; x++) {
if (deathMap[y][x]) {
_y = y;
_x = x;
if (rotation == 1) {
_x = 19 - y;
_y = x;
} else if (rotation == 2) {
_x = 19 - x;
_y = 19 - y;
} else if (rotation == 3) {
_x = y;
_y = 19 - x;
}
target.setPixel(_x, _y, blackWhite(target.getPixel(_x, _y)) );
}
}
}
The above code handles the rotation properly (the correct way is x=height-1-y, because of zero-indexing).
However:
Shouldn't
target.setPixel(_x, _y, blackWhite(target.getPixel(_x, _y)) );
be
target.setPixel(_x, _y, blackWhite(target.getPixel(x, y)) );
?
|
|
|
someone93
261 posts
|
Topic: Game Programming /
Solved, AS3 - fast way to implement simple 90 degrees rotation?
Guys, learn how to do these things properly.
var num:int = 0;
while(++num < 90) { obj.rotation += A(num, num); }
// Where A is some implementation of the Ackermann function
obj.rotation = num;
|
|
|
someone93
261 posts
|
Topic: Game Programming /
Instance names >:(
Why not spawn the instances through code? That would solve most of your problems.
|