This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Messages - nemo
1
« on: November 13, 2011, 05:34:59 pm »
you can never write too much when describing something. however, finding the angle of the ball is only that easy if the ball is falling from straight down, but looking at your game the ball isn't going to always fall straight down. unfortunately, i'm not sure how to calculate the angle. according to this code, to rotate the the line about the point you would have something like this: //point of rotation is always (48, 32) (the center of the screen) //the line is described as (X1,Y1) (X2,Y2) //Z is the angle of rotation... however Axe represents it. binary degrees? //A,B,C,D are all temp vars X1-48->A Y1-32->B X2-48->C Y1-32->D 48-(Acos(Z)-(Bsin(Z))->X1 32-(Asin(Z)-(Bcos(Z))->Y1 48-(Ccos(Z)-(Dsin(Z))->X2 32-(Csin(Z)-(Dcos(Z))->Y2
of course, i'm taking his word for it. i didn't actually do the math.
2
« on: November 13, 2011, 05:05:49 pm »
the equation for the line is Y=(B1-B2)/(A1-A2)*(X-A1)+B1 (this is point-slope form) so to find if a certain point (X,Y) is on that line, plug in X and see if you get Y.
to find angle C, find angle D and add 90°. angle D is calculated most easily by doing Tan-1((Y-B1)/(X-A1))
3
« on: November 09, 2011, 06:53:47 pm »
shouldn't the stationary turret be a building, not a unit, since it can't move? also, i'm interested in making a game like this to simulate and test out different game elements, albeit in java and not on a calculator
4
« on: November 05, 2011, 11:37:03 pm »
what's your end goal? to be able to ask your program a question and have it come up with a logical answer, or have it be able to break down the parts of a sentence i.e. sentences into clauses & phrases, clauses & phrases into individual parts of speech?
5
« on: November 03, 2011, 07:50:35 pm »
sorry for the off topic, but was the choosing of this name because it means "a game to give" in latin? in my latin class i get extra credit for external references (besides obvious ones like money, planets, etc) so it would benefit for me to know. it looks nice too!
6
« on: November 01, 2011, 06:01:21 pm »
7
« on: October 31, 2011, 01:35:35 am »
i've been going through the source code for this deciphering it trying to figure it all out, but i've hit a roadblock. In the SimZ function, what is the variable H used for? i think it's detecting if the object is moving horizontally, but i'm not sure.
8
« on: September 28, 2011, 11:38:47 pm »
I'm not sure what the status of this project is, but would it be possible to have an option to use a monospaced font like Courier?
Edit: nevermind, Tokens uses the monospaced font Consolas, which i didn't have on my computer.
9
« on: September 13, 2011, 07:54:07 pm »
do a System.out.println(getParent()); and System.out.println(mainFrame); and copy/paste the output
10
« on: September 04, 2011, 10:31:25 pm »
my approach would be to have an instance variable of javax.swing.Timer called timer in the Game class. then in the game constructor:
public Game(){ //other stuff timer = new Timer([MILLISECONDS], new ActionListener(){ public void actionPerformed(ActionEvent e){ //run whatever functions you want. }}); timer.start(); }
11
« on: August 19, 2011, 03:54:06 pm »
Again, you cannot add Graphics to the panel. JPanels have a Graphics instance variable already. i just noticed your method header for paintComponent is incorrect. it's parameter should be of type Graphics, not Graphics2D.
12
« on: August 18, 2011, 02:37:34 pm »
the exact some code is working on my computer. are you sure you saved/recompiled before you ran the code? also, what's the project you're working on?
13
« on: August 18, 2011, 02:23:55 pm »
yes, you aren't adding the game panel to the JFrame.
14
« on: August 18, 2011, 02:17:46 pm »
the Game class has a Graphics instance variable inherited from JPanel. you don't need to add it. you can access the graphics variable using paintComponent.
15
« on: August 18, 2011, 12:54:38 pm »
Graphics is also an abstract class, so that wouldn't work either. you can still split it into multiple files:
public class Runner{ public static void main(String[] args){ new Game().run(); } }
public class Game extends JPanel{ public Game(){ //set up JFrame } public void run(){ //show JFrame } public void paintComponent(Graphics g){ //paint things here } }
what are you making, by the way? if you're worried the paintComponent method will get too large because you have too many objects to draw e.g. you have an array of 100 enemies, your character, the background, the tilemap etc. just make an Enemy, Character, Tilemap class and have them each have a draw(Graphics) method.
|