Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!

We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Member Since 20 Aug 2008
Offline Last Active Jan 08 2013 12:20 AM

Topics I've Started

Help me figure out what I'm doing wrong, please!

16 September 2012 - 07:15 PM

So I've read a good bit of a couple of books on Java. Java: The Complete Reference 8th edition by oracle press, and Java: How to Program 8th edition by Deitel. Mind you, I never finished either book, only halfway through each, so maybe that's why I can't figure this out. Or perhaps I'm just being a complete retard that's been working all day on his first real class and has brain freeze, lol. So anyway, here's the code:

[source lang="java"]import java.util.Random;public class Planet { private Random rand; private double mass; private double xPos, yPos; private double xVel, yVel; /** constructors */ Planet(){ setMass(); setPos(); setVelocity(); } Planet(double m){ mass = m; setPos(); setVelocity(); } Planet(double x, double y){ setMass(); xPos = x; yPos = y; setVelocity(); } Planet(double x, double y, double m){ mass = m; xPos = x; yPos = y; setVelocity(); } Planet(double x, double y, double i, double j, double m){ mass = m; xPos = x; yPos = y; xVel = i; yVel = j; } /** returns distance from calling object * * @param x is the xPos of the calling object * @param y is the yPos of the calling object */ double distance(double x, double y){ double distX = Math.abs(xPos - x); double distY = Math.abs(yPos - y); return Math.sqrt(distX * distX + distY * distY); } /** returns unit-length x vector pointing from this to calling object * * @param x is the xPos of calling object * @param dist is the value returned from distance() */ double dirX(double x, double dist){ return (x - xPos) / dist; } /** returns unit-length y vector pointing from this to calling object * * @param y is the yPos of calling object * @param dist is the value returned from distance() */ double dirY(double y, double dist){ return (y - yPos) / dist; } /** calculates acceleration scalar for calling object * * @param m is the mass of the calling object * @param dist is the value returned from distance() */ double accelScalar(double m, double dist){ return (6.674e-11 * m) / (dist * dist); } /** translates this object on XY plane. * should be called before accelerate. */ void translate(){ xPos += xVel; yPos += yVel; } /** determines delta V for calling object. * should be called after translate. * * @param as is the value returned from accelScalar() * @param dX is the value returned from dirX() * @param dY is the value returned from dirY() */ void accelerate(double as, double dX, double dY){ xVel += as * dX; yVel += as * dY; } void setMass(){ double d = rand.nextDouble() * 10.0; int e = (Math.abs(rand.nextInt()) % 6) + 22; setMass(d, e); } void setMass(double d, int e){ mass = Math.pow(d, e); } void setPos(){ int w = 800; int h = 600; double x = rand.nextDouble() * w; double y = rand.nextDouble() * h; setPos(x, y); } void setPos(double x, double y){ xPos = x; yPos = y; } void setVelocity(){ double x = rand.nextDouble() * 50000.0; double y = rand.nextDouble() * 50000.0; setVelocity(x, y); } void setVelocity(double x, double y){ xVel = x; yVel = y; } double[] getPos(){ double[] pos = {xPos, yPos}; return pos; } double[] getVelocity(){ double[] vel = {xVel, yVel}; return vel; } double getXPos(){ return xPos; } double getYpos(){ return yPos; } double getXVelocity(){ return xVel; } double getYVelocity(){ return yVel; } public String toString(){ return "X: " + xPos + "\tY: " + yPos; } }[/source]

I'm getting a NullPointerException argument at line 129, the setMass() method. It works perfectly fine when I build the object using the full set of constructor arguments. Can anyone tell me where my problem is?

VC# '05, or VC# '08....which one should I learn on?

21 August 2008 - 11:13 AM

I have downloaded both some time ago, and now I'm starting to get more serious about learning. I downloaded '05 because XNA was only available for that one, but I downloaded '08 as well, if only because, hey, it's there. Unfortanately though, I don't know which one I should spend more time learning. I'm leaning towards '08, because by the time I'm ready for my first games, the full XNA 3 will be available. I appreciate your thoughts on the matter, and if this was already posted by someone else, or answered in a FAQ, I appologize for the redundancy, but I'm on my way to the shower and off to borders for a book to start learning. I'll be purchasing whichever one you guys recommend, based on '05 or '08, or I'll just think of which version to go through while I'm there :-D. Thanks for your time.

Am I to old to start?

20 August 2008 - 10:14 PM

I would like to start off by saying thank you to all that reads/responds to this post, and any and all responces will be greatly appreciated. So off to the topic. I'll be turning 28 next month, and just started to relearn programming. When I was a kid, I used to make simple text based games on my commodore 64 (ouch, I'm old). Ever since then, I always wanted to get into the gaming industry. Unfortunately though, I took that "year off" from school after graduating, got a job, and 10 years later...no progress. But enough of that sob story... At 28 years old, is that to late to try to get into the business? I AM going to go to school pretty soon, and definately will take these courses as I would love to have this knowledge for a hobby at the least, but if it's to late for me, it'll be a minor. If the general response is that I'm an old fart already down one hill and goin up the next, any other options for a geezer like me to get into the wonderful world of video games? Or is every field lookin for young studs, and kickin' the grandpas like me to the street? Oh, and as a post script, please feel free to make fun of my inquiries, as both positive and negative feedback is always aprreciated, and most likely helpful for me or anyone else that reads this, if just for the simple amusement. :-) Thanks :-), Kirkula