avatar for QuantumFTL

About me

I'm a Systems Engineer for a top-tier defense contractor by day, and badass motherf**ker by night.

  • Member Since: Jul. 13, 2007
  • Last Login: Nov. 16, 2009
  • Current Points: 1748
  • Comments: 1
  • Location: Cambridge, MA
  • Age: 27
  • Sex: Male
Latest Achievements
 
Sesquipedalian (completed)
Sesquipedalian (completed)
Sesquipedalian Badge (medium - 15 points)
Deal 100 damage with a single word in Clockwords: Prelude
Acquired Oct. 31, 2009

Shouts & Whispers

Shouts
Whispers
Person Content
avatar for dahnraelz
dahnraelz Developer_icon
Dec. 03, 2008

HA! That looks insane. But I’ll have a look at it as everything about maths or physics interests me. I am not good in school though :D

avatar for dahnraelz
dahnraelz Developer_icon
Dec. 03, 2008

Believe me, there nothing to benefit from in the elastic’s code. It’s so horrible it could be a perfect example of how not to code. Go along with the shootorials if you haven’t already.

The mechanics are quite easy to write.

The square goes like this:
dist_x = (root.player.x-x)*speedModifier;
dist
y = (root.player.y-y)*speedModifier;
xspeed += dist
x;
yspeed += dist_y;
xspeed *= friction;
yspeed *= friction;
_x += xspeed;
_y += yspeed;

It’s really easy. It just finds the distance and then adds it to speed, of course multiplied by speedModifier (0.0X), otherwise, it would be instant.

The laser aiming towards square is also quite easy, although I think I used the wrong function:
angle = Math.atan(Math.sqrt((Ax-Bx))/Math.sqrt((Ay-By)(Ay-By)))/0.0174532925;
It’s just simple maths, that are hidden behind code. This is simply tan-1 of angle equals to opposite divided by adjacent. Simple trig. There are the squareroots etc to always keep it positive (maybe there is some function for it, dunno) and the /0.017.. to change it to degrees from radians.
The problem with this is that it doesn’t really say in what corner of the imaginary circle the square is, so I had to use this code to find that out:

if (By > Ay)
{
if (Ax > Bx)
{
angle = 180 + angle;
}
else
{
angle = 180 – angle;
}
}
else
{
if (Ax > Bx)
{
angle = 360 – angle;
}
else
{
}
}
I’ve read about Math.atan2 and how it solves this. I didn’t really understand but it clearly described this problem so I guess it really is the solution and I just didn’t use it right.

Thats pretty much evertyhing, anything else can be learned from the shootorials.

avatar for dahnraelz
dahnraelz Developer_icon
Dec. 03, 2008

Thanks. :)
I am not going to release the source as it is BAAAD. Seriously, it’s a mess I can’t understand at all, as I had absoultely no previous experience with coding.
But all it has is just shootorial code + basic trigonometry + pytaghorean theorem. I can provide you further explanation about how are the things done if you are unsure.

As for the comments about the actual game, well, to be honest I am ashamed of presenting myself with this buggy and glitchy game. It didn’t use it’s potential at all and I know about all the flaws and problems. Thats why I am definitely going to use this game mechanics in some of my later games, possibly making Elastic 2 or so.

QuantumFTL's comments

Game Comments
Play Eternal Red
Eternal Red
Dec. 04, 2008
Interesting game, however it is not properly balanced - it is possible to make it far into the game without using the "shooter" aspect. Proper combination of spikes + slow + machine gun pretty much takes everything out. "hardcore" mode should not be so easy :-P
Click Here