Recent posts by LunarLady on Kongregate

Flag Post

Topic: Forum Games / destroy the fort!

Isn’t falling based on gravity?

 
Flag Post

Topic: Forum Games / destroy the fort!

Sorry if it’s been done, but

Care Bear STARE!!!

That is all.

EDIT: I am defending the fort.

 
Flag Post

Topic: Game Programming / Help with this bloody button?

I’m working on this one button and this single topic has taken up over of month of my time. I can make the button, I can display button but I can’t make it do anything when clicked.

I’ve tried

package role.play.generator;
import java.util.Random;
import java.awt.;
import javax.swing.
;
public class RolePlayGenerator {
public static void main(String[] args) {
//Make the Window
JFrame frame = new JFrame(“Random Role-Play Generator”);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
// I’m not wuite sure what this does \/
Random randomgenerator = new Random();
// Random Selector code
int hairsel = randomgenerator.nextInt(5);
int clothsel = randomgenerator.nextInt(4);
// Arrays
String[] clothtypes = {"Dress",“Skirt”,“Robe”,"Pants"};
String[] haircolours = {"Blue", “Red”, “Blonde”,“Black”,"Purple"};
//Height Generator
double height = Math.floor(Math.random()9+58);
// Variable section
String Haircolour="Hair Colour: " + haircolours[hairsel] + " “;
String Clothing=”Clothing: " + clothtypes[clothsel] + " ";
String Height = "Height: “height” Inches “;
String Display = Height + Clothing + Haircolour;
// Create Labels
JLabel HeightLabel = new JLabel(Display,SwingConstants.CENTER);
HeightLabel.setPreferredSize(new Dimension(400,100));
JButton button = new JButton();
button.setText(”Regenerate");
// Button Commands
button.addMouseListener(new MouseListener(){
hairsel = randomgenerator.nextInt(5);
clothsel = randomgenerator.nextInt(4);
height = Math.floor(Math.random()
9+58);
Height = “Height=”+height+" Inches “;
Haircolour=”Hair Colour: " + haircolours[hairsel] + " “;
Clothing=”Clothing: " + clothtypes[clothsel] + " ";
Height = "Height: “height” Inches ";
Display = Height + Clothing + Haircolour;
})
frame.getContentPane().add(HeightLabel, BorderLayout.CENTER);
frame.getContentPane().add(button, BorderLayout.SOUTH);
frame.setLocationRelativeTo(null);
frame.pack();
frame.setVisible(true);
}
}

It keeps saying it requires “MouseListener” and it find “anonymous MouseListener”

Any help would be greatly appreciated.

 
Flag Post

Topic: Game Programming / Java out of bounds error?

Thank you Octa, It works brilliantly now.

 
Flag Post

Topic: Game Programming / Java out of bounds error?

So I have this code

package role.play.generator;
import java.util.Random;
public class RolePlayGenerator {
    public static void main(String[] args) {
        Random randomgenerator = new Random();
        int hairsel = randomgenerator.nextInt()%5;
        String[] haircolours = {"Blue", "Red", "Blonde","Black","Purple"};
        double height = Math.floor(Math.random()*9+58);
        System.out.println("Height is " + height + " Inches");
        System.out.println(haircolours[hairsel]);
    }
}

And I keep getting this error

-2
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -2
	at role.play.generator.RolePlayGenerator.main(RolePlayGenerator.java:11)
Java Result: 1

The -2 changes but always stays negative how can I fix this? Every thing else works perfectly.

 
Flag Post

Topic: Game Programming / Bit of help with this Java script?

Got it working by reorganizing the code to make it all static, and it ran perfectly.
The new and working code is

package height_generator;
import java.util.Random;
public class Height_generator {

    public static void main(String[] args) {
        Random randomGenerator = new Random();
        int ary1 = randomGenerator.nextInt() % 4;
        int select = randomGenerator.nextInt();
        String[] aryhair = {"Blue","Red","Black","Blonde"};
        double ranheight = Math.floor(Math.random()*9+58);
        System.out.println(ranheight+" Inches Tall");
        System.out.println(aryhair[ary1]);
        }
}

LoL

 
Flag Post

Topic: Game Programming / Bit of help with this Java script?

All I need to do is get the array to output a random colour.

package height_generator;
import java.util.Random;
public class Height_generator {
    Random randomGenerator = new Random();
    int select = randomGenerator.nextInt();
    public static void main(String[] args) {
        String[] aryhair = {"Blue","Red","Black","Blonde"};
        double[] ary1 = {Math.floor(Math.random()*4)};
        double ranheight = Math.floor(Math.random()*9+58);
        System.out.println(ranheight+" Inches Tall");
        System.out.println(aryhair[ary1[0]]);
        }
}

It’s incredibly difficult and I just can’t get it to work.