Show Posts

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

Pages: 1 ... 18 19 [20] 21 22 ... 82
286
TI Z80 / Re: YAAR (Yet Another Axe Raycaster)
« on: December 14, 2010, 11:19:39 am »
whoa.. that is insane. only 2000 bytes? great work runer

287
Other / Re: 1760 PS3s = supercomputer
« on: December 13, 2010, 09:49:19 pm »
so... anyone have 1760 PS3's lying around ;)

288
lol you aren't bothering me! if you can't find something in the API i'd be glad to help. like if you want to display an image, and then after that you want to rotate it. and after that you want to make a racing game that scrolls. i can help you along there  :)

289
Do you know what the API is? in general, they'll give methods for you to do most anything you can do in java. i'm not explaining how and just giving you a link to be rude, it's so that everytime you want to do something new in java, you can look at the API to see if there's a method that does what you want.

290
yep, that should do the trick.

291
no, they aren't supposed to display. the panel has two instance objects called the InputMap and the ActionMap. the inputmap is basically a bunch of strings that each correspond to a specificy keyStroke. the actionmap reads the inputmap's strings and maps the strings onto a bunch of Action objects, which run that code whenever you press the keyStroke in the inputmap.

and yes it should, if you make the smile's x and y positions be based upon x and y variables.

292
yeah it was a headache to write  :banghead:

i haven't built the framework for keypresses in so long. i kept having to refer back to my game Juggernaut.

293
lol a smilie. nice. here's example four. it's pretty.. badly coded. everything is declared static  <_< i wish main didn't have to be static. it's a very inelegant solution to modifier problem, but the concepts are shown.

Code: [Select]
//program: makes an empty window with a panel. oh, and the panel has a red circle in the center. yay.
import javax.swing.*;  //for JPanel, JFrame
import java.awt.*; // for Color, and Container pane
import java.awt.event.*; //needed for the key movement
import java.awt.Graphics; //idk why, but my IDE needs this whenever i use graphics. BlueJ may not.

public class Example4{
static boolean isMovingLeft = false;
static boolean isMovingRight = false;
static boolean isMovingUp = false;
static boolean isMovingDown = false;
static int x = 0, y = 0;
static Timer t; //for timed events. like every 100 milliseconds do this action
static MagicPanel panel;
public static void main(String[] args){
JFrame frame = new JFrame("Omnimaga."); //makes a new window with the title "Omnimaga." in memory.
Container pane = frame.getContentPane(); //this is what organizes buttons, text boxes, panels, etc.
panel = new MagicPanel(); //you can draw on this! yay!
InputMap i = panel.getInputMap(); //this allows you to define keystrokes the panel should recognize.
ActionMap a = panel.getActionMap(); //this allows you to transfer those keystrokes into actions.
i.put(KeyStroke.getKeyStroke("LEFT"),"move left!"); //maps the pressed key "LEFT" (left arrow key) to the string "move left!"
i.put(KeyStroke.getKeyStroke("RIGHT"),"move right!"); //like above..
i.put(KeyStroke.getKeyStroke("UP"),"move up!");
i.put(KeyStroke.getKeyStroke("DOWN"),"move down!");
i.put(KeyStroke.getKeyStroke("released LEFT"),"stop moving left!"); //maps the released key "LEFT" (left arrow key) to the string "stop moving left!"
i.put(KeyStroke.getKeyStroke("released RIGHT"),"stop moving right!");
i.put(KeyStroke.getKeyStroke("released UP"),"stop moving up!");
i.put(KeyStroke.getKeyStroke("released DOWN"),"stop moving down!");
a.put("move left!",moveLeft); //maps the string in the InputMap "move left!" to the action moveLeft.
a.put("move right!",moveRight);//like above..
a.put("move up!",moveUp);
a.put("move down!",moveDown);
a.put("stop moving left!",stopMovingLeft);
a.put("stop moving right!",stopMovingRight);
a.put("stop moving up!",stopMovingUp);
a.put("stop moving down!",stopMovingDown);
panel.setFocusable(true); //allows the panel to intercept key presses.
pane.add(panel); //add it to the panel!
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //makes it so when you press the red X, the program exits.
frame.setSize(300,400); //300 pixels wide by 400 tall.
frame.setResizable(true); //it's resizable by default, but if you ever want to make it not-resizable, you know how.
frame.setVisible(true); //yay! it's visible!
t = new Timer(1,update); //do action update every 1 millisecond
t.start(); //start the timer
while(true){
panel.repaint();
}
}

static Action update = new AbstractAction(){ //timer's action
public void actionPerformed(ActionEvent e){
panel.updateCoordinates(x,y);
if(isMovingLeft)
x--;
if(isMovingRight)
x++;
if(isMovingUp)
y--;
if(isMovingDown)
y++;
}
};

static Action moveLeft = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingLeft = true;
}
};
static Action moveRight = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingRight = true;
}
};
static Action moveUp = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingUp = true;
}
};
static Action moveDown = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingDown = true;
}
};
static Action stopMovingLeft = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingLeft = false;
}
};
static Action stopMovingRight = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingRight = false;
}
};
static Action stopMovingUp = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingUp = false;
}
};
static Action stopMovingDown = new AbstractAction(){
public void actionPerformed(ActionEvent e){
isMovingDown = false;
}
};

}

class MagicPanel extends JPanel{ //it's like a jpanel... but magic...
private int x,y; //where the circle would be placed

public void updateCoordinates(int xPos, int yPos){
x = xPos;
y = yPos;
}
public void paintComponent(Graphics g){
g.setColor(Color.BLACK); //everything painted is black
g.fillRect(getX() , getY() , getWidth(), getHeight() );
g.setColor(Color.RED); //everything you paint will be red now.
g.fillOval(x ,y, 50,50);
}

}

294
i don't know. i don't work with applets.

295
Code: [Select]
//program: makes an empty window you can move around, minimize. whatever.
import javax.swing.*;

public class Example1{
public static void main(String[] args){
JFrame frame = new JFrame("Omnimaga."); //makes a new window with the title "Omnimaga." in memory.
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //makes it so when you press the red X, the program exits.
frame.setSize(300,400); //300 pixels wide by 400 tall.
frame.setResizable(true); //it's resizable by default, but if you ever want to make it not-resizable, you know how.
frame.setVisible(true); //yay! it's visible!
}
}

example numero one.

Code: [Select]
//program: makes an empty window with a panel, which has a black background.
import javax.swing.*;  //for JPanel, JFrame
import java.awt.*; // for Color, and Container pane

public class Example2{
public static void main(String[] args){
JFrame frame = new JFrame("Omnimaga."); //makes a new window with the title "Omnimaga." in memory.
Container pane = frame.getContentPane(); //this is what organizes buttons, text boxes, panels, etc.
JPanel panel = new JPanel(); //you can draw on this! yay!
panel.setBackground(Color.BLACK); //make the background color black
pane.add(panel); //add it to the panel!
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //makes it so when you press the red X, the program exits.
frame.setSize(300,400); //300 pixels wide by 400 tall.
frame.setResizable(true); //it's resizable by default, but if you ever want to make it not-resizable, you know how.
frame.setVisible(true); //yay! it's visible!
}
}

example nummer zwei.


3 is on its way. they're starting to get more complex.

Code: [Select]
//program: makes an empty window with a panel. oh, and the panel has a red circle in the center. yay.
import javax.swing.*;  //for JPanel, JFrame
import java.awt.*; // for Color, and Container pane
import java.awt.Graphics; //idk why, but my IDE needs this whenever i use graphics. BlueJ may not.

public class Example3{
public static void main(String[] args){
JFrame frame = new JFrame("Omnimaga."); //makes a new window with the title "Omnimaga." in memory.
Container pane = frame.getContentPane(); //this is what organizes buttons, text boxes, panels, etc.
MagicPanel panel = new MagicPanel(); //you can draw on this! yay!
pane.add(panel); //add it to the panel!
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //makes it so when you press the red X, the program exits.
frame.setSize(300,400); //300 pixels wide by 400 tall.
frame.setResizable(true); //it's resizable by default, but if you ever want to make it not-resizable, you know how.
frame.setVisible(true); //yay! it's visible!
}
}

class MagicPanel extends JPanel{ //it's like a jpanel... but magic...

public void paintComponent(Graphics g){
g.setColor(Color.BLACK); //everything painted is black
g.fillRect(getX() , getY() , getWidth(), getHeight() );
g.setColor(Color.RED); //everything you paint will be red now.
g.fillOval(getWidth() / 2 ,getHeight() / 2, 50,50);  //oval upper-left X position is the panel's width / 2,
// y position is the panel's height / 2
//width is 50 pixels, and then height is 50 pixels.
}

}
numeri tres! you'll notice that the red circle isn't *completely* in the center of the panel. that's because of the edges of the window. if you're in XP, the extra height is +34 and the extra width is +4.

296
isn't JPanel and JFrame Applet stuff?

nope, it's called Swing. it allows you to have little windows on your computer. i think i should give multiple examples....

297
i'm in APCS as well, i use JCreator Lite. my teacher got the free version before it started costing money.
i'll have some code up in a sec. do you guys know what a JFrame or JPanel are or should i comment the basic elements too?

298
Other Calculators / Re: Peggle
« on: December 13, 2010, 07:01:07 pm »
For some reasons, 3 of your games got names that are similar or exactly the same as 3 other existing games. :P (Trapped, Orbit and Pegs) Nice games, though.
I just need to build up the courage to made a pinball engine in Axe first :P
O.O
if you made this in axe i would love you forever. the idea is great, but TI-Basic is too slow to showcase all of peggle's glory.
No, I think Builderboy game is good in BASIC too. I understand that Axe blew BASIC out of the water in some ways but let's not start that whole basic bashing thing again.

Sorry DJ, not meaning to start basic bashing. i sent you a lengthy pm describing why i'm not bashing basic in that post. i just mean that peggle is more suited to be made in axe or assembly, due to how much math it has to calculate per-frame.

299
Other Calculators / Re: Peggle
« on: December 13, 2010, 05:39:29 pm »
if you made this in axe i would love you forever. the idea is great, but TI-Basic is too slow to showcase all of peggle's glory.

300
Computer Projects and Ideas / Re: Juggernaut
« on: December 13, 2010, 05:34:25 pm »
It seems like they might. i'm not 100% sure because i can't get executables of the actual contest winners. it just seems the winners are more educationally inclined, though that could be because the games submitted were poorly made, or there were few. i know that a half-made RPG was an "honorable mention", but i don't plan on giving a half-made platformer.

the great thing was i didn't even know i had a headshot. i was hoping the laser showed up ;)

Pages: 1 ... 18 19 [20] 21 22 ... 82