This site requires JavaScript, please enable it in your browser!
Greenfoot back
Game/maniac
Game/maniac wrote ...

2013/5/31

GREENFOOT DARE #1 THEME VOTE

1
2
Game/maniac Game/maniac

2013/5/31

#

VOTE FOR THE THEME OF THE FIRST GREENFOOT DARE HERE!

To vote reply to this discussion. Themes to choose from: -Evolution -Prehistoric -Old -New -Future -Space -Science -Nature -Destruction -8-bit -Economic -Invasion -God -Potato -Endless -Italian -War -Animals -The Big Bang -Decoration -Binary -Social
Game/maniac Game/maniac

2013/5/31

#
Example reply: Evolution
Duta Duta

2013/5/31

#
Ahhhhhhhhhhhh I can't choose. Either 8-bit or endless. If I have to give one, 8-bit.
JetLennit JetLennit

2013/5/31

#
8-Bit (and can I do it next year?)
MatheMagician MatheMagician

2013/5/31

#
-Destruction -Economic -Invasion
Game/maniac Game/maniac

2013/6/1

#
@JetLennit Ok
Game/maniac Game/maniac

2013/6/1

#
What should be added to the list in the next GREENFOOT DARE to replace the chosen theme?
Game/maniac Game/maniac

2013/6/1

#
DON'T FORGET TO VOTE! VOTING ENDS NEXT WEEK!
GreenGoo GreenGoo

2013/6/1

#
Definitely evolution. That would be so cool.
Solringolt Solringolt

2013/6/1

#
I'm actually making a game about a cell that evolves, so... evolution!
GreenGoo GreenGoo

2013/6/1

#
I can't wait to play it in that case. I tried to do the same but it was way too difficult for me.
8-bit
Duta Duta

2013/6/1

#
I made a 256-color class last night that people can use if they want (in case it's the 8-bit challenge):
import java.awt.Color;
import greenfoot.Greenfoot;
/**
 * An 8-bit color class.
 */
public class Color8 extends Color {
    // The 256-color palette.
    public static final Color8[] PALETTE = generatePalette();
    // Some colors from the palette (named for easier use).
    public static final Color8
        BLACK = PALETTE[0],
        BLUE = PALETTE[5],
        LIGHT_BLUE = PALETTE[23],
        GREEN = PALETTE[18],
        LIGHT_GREEN = PALETTE[24],
        LIME_GREEN = PALETTE[30],
        CYAN = PALETTE[71],
        PURPLE = PALETTE[77],
        BROWN = PALETTE[78],
        RED = PALETTE[108],
        PINK = PALETTE[185],
        ORANGE = PALETTE[196],
        LIGHT_PINK = PALETTE[209],
        YELLOW = PALETTE[210],
        WHITE = PALETTE[215],
        TRANSPARENT = PALETTE[255];
        
    
    /**
     * Creates a Color using the given values.
     *
     * @param r The red value
     * @param g The green value
     * @param b The blue value
     */
    private Color8(int r, int g, int b) {
        super(r, g, b);
    }
    
    /**
     * Creates a Color using the given values.
     * Includes an alpha channel
     *
     * @param r The red value
     * @param g The green value
     * @param b The blue value
     * @param a The alpha value
     */
    private Color8(int r, int g, int b, int a) {
        super(r, g, b, a);
    }
    
    /**
     * Returns a random color from the palette.
     * (uses only the 0 <= x <= 216 region)
     * 
     * @return A random color in the region PALETTE[0] to PALETTE[216]
     */
    public static Color8 randomColor() {
        return randomColor(0, 216);
    }
    
    /**
     * Returns a random color from the given
     * range of the palette.
     *
     * @param min The min (inclusive) index to choose
     * @param max The max (exclusive) index to choose
     * @return A random color in the region PALETTE[min] to PALETTE[max]
     */
    public static Color8 randomColor(int min, int max) {
        int val = min + Greenfoot.getRandomNumber(max - min);
        return PALETTE[val];
    }
    
    /**
     * Generates the color palette.
     * Uses the "safety palette" from
     * http://msdn.microsoft.com/en-us/library/bb250466(VS.85).aspx
     * for the first 216 colors. The
     * last 40 are subject to change
     * (they are to be used for whichever
     * colors are needed and not found in
     * the default palette).
     * 
     * Here is an image of the generated
     * pallete: http://i.imgur.com/KqMpfkx.png
     * 
     * Current custom colors usage:
     *  - 255: Transparent
     * 
     * @return A 256-color palette
     */
    private static Color8[] generatePalette() {
        Color8[] palette = new Color8[256];
        // Do the first 216 colors
        int i = 0;
        for(int r = 0; r < 256; r += 51) {
            for(int g = 0; g < 256; g += 51) {
                for(int b = 0; b < 256; b += 51) {
                    palette[i] = new Color8(r, g, b);
                    i++;
                }
            }
        }
        // Initialize the rest to black for now
        for(; i < 256; i++) {
            palette[i] = new Color8(0, 0, 0);
        }
        // Do any custrom colors here
        palette[255] = new Color8(0, 0, 0, 0);
        return palette;
    }
}
Because it extends Color, you can use it in your code easily. Example: Code:
import greenfoot.*;
public class TestWorld extends World {
    public TestWorld() {
        super(200, 200, 1);
        GreenfootImage image = new GreenfootImage(200, 200);
        image.setColor(Color8.PURPLE);
        image.fill();
        int size = 20;
        for(int x = 0; x < image.getWidth()/size; x++) {
            for(int y = 0; y < image.getHeight()/size; y++) {
                image.setColor(Color8.randomColor());
                image.fillRect(x * size, y * size, size, size);
            }
        }
        setBackground(image);
    }
}
Output:
THE BIG BANG! BOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOM!!!!!!!!!!!! The DoctorProfessor is out!
Chocomint1213 Chocomint1213

2013/6/5

#
8-bit
There are more replies on the next page.
1
2