Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* PLANNING-
- Draw - Alphabet
- function list:
- draw circle
- drawLine
- drawRectangle
- */
- function start(){
- var Bg = drawRectangle(X_MAX * 2,Y_MAX,Color.green,0,0);
- GuessRoll();
- drawDice_cube();
- RollDice();
- }
- var centerX = getWidth() / 2;
- var centerY = getHeight() / 2;
- var X_MAX = getWidth();
- var Y_MAX = getHeight();
- var Reflection_Dot = 8;
- var Reflection_Dot_radius = 3;
- var roll = Randomizer.nextInt(1,6);
- var guess = readInt("What number do you think the dice will roll?");
- function drawCircle(color, x, y, radius,){
- var circle = new Circle(radius);
- circle.setPosition(x,y);
- circle.setColor(color);
- add(circle);
- }
- function drawLine(color, width, x1, y1, x2, y2){
- var line = new Line(x1, y1, x2, y2);
- line.setColor(color);
- line.setLineWidth(width);
- add(line);
- }
- function drawRectangle(width, height, color, x, y){
- var rectangle = new Rectangle(width, height);
- var left = x - width/2;
- rectangle.setPosition( left , y);
- rectangle.setColor(color);
- add(rectangle);
- }
- function drawDiceDot(x, y){
- drawCircle(Color.black, x, y, 15);
- drawCircle(Color.white, x, (y+ Reflection_Dot), Reflection_Dot_radius);
- }
- function drawDice_cube(){
- drawRectangle(200, 200, Color.black, 200, 200);
- drawRectangle(190, 190, Color.white, 200, 205);
- drawLine(Color.black, 4, 105, 205, 50, 175);//top left
- drawLine(Color.black, 4, 300, 203, 250, 175);//top right
- drawLine(Color.black, 4, 50, 175, 250, 175)//conector line
- drawLine(Color.black, 4, 50, 370, 100, 396);//bottom left
- drawLine(Color.black, 4, 50, 175, 50, 370);
- var side1 = new Polygon(100, 100);
- side1.addPoint(100,203);
- side1.addPoint(52, 178);
- side1.addPoint(52, 370);
- side1.addPoint(100, 393);
- side1.setColor("White");
- add(side1);
- var side2 = new Polygon(100, 100);
- side2.addPoint(52, 176);//top left
- side2.addPoint(99, 200);//bottom left
- side2.addPoint(300, 200);//bottom right
- side2.addPoint(250, 176);//top right
- side2.setColor("White");
- add(side2);
- }
- function RollDice(){
- for(var i = 0; i < 1; i++){
- if (roll == 1){
- drawOne();
- } if (roll == 2){
- drawTwo();
- } if (roll == 3){
- drawThree();
- } if (roll == 4){
- drawFour();
- } if (roll == 5){
- drawFive();
- } if (roll == 6){
- drawSix();
- }
- } //for
- }//function
- function drawOne(){
- drawDiceDot(200, 300);
- }
- function drawTwo(){
- drawDiceDot(200, 250);
- drawDiceDot(200, 330);
- }
- function drawThree(){
- drawDiceDot(200, 300);
- drawDiceDot(240, 340);
- drawDiceDot(160, 260);
- }
- function drawFour(){
- drawDiceDot(240, 340);//bottom right
- drawDiceDot(160, 260);
- drawDiceDot(240, 260);
- drawDiceDot(160, 340); //bottom left
- }
- function drawFive(){
- drawDiceDot(240, 340);//bottom right
- drawDiceDot(160, 260);
- drawDiceDot(240, 260);
- drawDiceDot(160, 340); //bottom left
- drawDiceDot(200, 300);//middle
- }
- function drawSix(){
- drawDiceDot(240, 350);//bottom right
- drawDiceDot(160, 250);
- drawDiceDot(240, 250);
- drawDiceDot(160, 350); //bottom left
- drawDiceDot(240, 300);
- drawDiceDot(160, 300);
- }
- function GuessRoll(){
- println("The dice rolled a " + roll);
- println("You guessed it will roll a " + guess);
- if (guess == roll){
- println("Your guess was correct");
- var Bg = drawRectangle(X_MAX * 2,Y_MAX,Color.green,0,0);
- var txt = new Text("Correct","50pt Arial");
- txt.setPosition(20, 70);
- add(txt);
- }else{ println("Your guess was incorrect");
- var Bg = drawRectangle(X_MAX * 2,Y_MAX,Color.red,0,0);
- var txt = new Text("Incorrect","50pt Arial");
- txt.setPosition(20, 70);
- setTimer(ChangeText, 2000);
- add(txt);
- }
- }
- function ChangeText(){
- var txt = new Text("Incorrect","50pt Arial");
- txt.setText("Try again!");
- txt.setPosition(20,120);
- add(txt);
- }
Add Comment
Please, Sign In to add comment