# Ryan's Concept, Made in JES by Tom # ---------------------------------- # import javax.swing.JOptionPane as JOptionPane # Global Variables are Here # The Turn currentTurn = 0 # Workers for the Player playerWorkers = 0 # Marines for the Player playerMarines = 0 # Money for the Player playerMoney = 0 # UI Primary Colour UIPrimary = 0 # UI Secondary Colour UISecondary = 0 # UI Boolean UIBoolean = 0 # UI Canvas myCanvas = makeEmptyPicture(751,601) # What you want to run to start it def StartUp(): # choose a team colour UIColour = requestString("Choose A Team Colour. Red or Blue?") if UIColour == "Red": global UIPrimary UIPrimary = red global UISecondary UISecondary = orange global UIBoolean UIBoolean = 0 global myCanvas myCanvas = makeEmptyPicture(751,601) show(myCanvas) # starts the game, making it Turn 1 nextTurn() # makes the UI createUI() else: if UIColour == "Blue": global UIPrimary UIPrimary = blue global UISecondary UISecondary = cyan global UIBoolean UIBoolean = 1 global myCanvas myCanvas = makeEmptyPicture(751,601) show(myCanvas) # starts the game, making it Turn 1 nextTurn() # makes the UI createUI() else: JOptionPane.showMessageDialog(None,"Input not valid. Please try again.","E rror",JOptionPane.WARNING_MESSAGE) StartUp() # Global Variables are hard to modify, so I've made a batch of defs so that you can then access to change them # Changes the turn def nextTurn(): global currentTurn currentTurn += 1 global playerMoney newMoney = playerWorkers * 50 playerMoney = (playerMoney + newMoney) # Changes the amount of Player Workers def changePlayerWorkers(change): global playerWorkers playerWorkers += int(change) # Changes the amount of Player Workers def changePlayerMarines(change): global playerMarines playerMarines += int(change) # Changes the amount of Player Money def changePlayerMoney(change): global playerMoney playerMoney += int(change) # This def creates the UI def createUI(): # make a blank picture for pixel in getPixels(myCanvas): setColor(pixel, white) repaint(myCanvas) # draw some lines to make it cool #addline(picture, startx, starty, endx, endy, colour) addLine(myCanvas, 1, 1, 249, 1, UISecondary) addLine(myCanvas, 1, 1, 1, 599, UISecondary) addLine(myCanvas, 1, 599, 249, 599, UISecondary) addLine(myCanvas, 249, 1, 249, 599, UISecondary) addLine(myCanvas, 251, 1, 251, 599, UISecondary) addLine(myCanvas, 749, 1, 749, 599, UISecondary) addLine(myCanvas, 251, 1, 749, 1, UISecondary) addLine(myCanvas, 251, 599, 749, 599, UISecondary) addLine(myCanvas, 249, 299, 749, 299, UISecondary) addLine(myCanvas, 251, 301, 749, 301, UISecondary) addLine(myCanvas, 499, 1, 499, 749, UISecondary) addLine(myCanvas, 501, 1, 501, 749, UISecondary) addLine(myCanvas, 250, 300, 750, 300, UIPrimary) addLine(myCanvas, 500, 0, 500, 750, UIPrimary) addLine(myCanvas, 0, 0, 750, 0, UIPrimary) addLine(myCanvas, 0, 0, 0, 600, UIPrimary) addLine(myCanvas, 0, 600, 750, 600, UIPrimary) addLine(myCanvas, 250, 0, 250, 600, UIPrimary) addLine(myCanvas, 750, 0, 750, 600, UIPrimary) # Make a header style to use later headerStyle = makeStyle(sansSerif, bold, 18) boldStyle = makeStyle(sansSerif, bold, 12) # draw some text # draw the team colour if UIBoolean == 0: myString = "Red" else: myString = "Blue" addTextWithStyle(myCanvas, 15, 25, (myString + " Team"), headerStyle, UIPrimar y) addTextWithStyle(myCanvas, 265, 25, "Buildings", headerStyle, UIPrimary) addTextWithStyle(myCanvas, 265, 325, "Technology", headerStyle, UIPrimary) addTextWithStyle(myCanvas, 515, 25, "Units", headerStyle, UIPrimary) addTextWithStyle(myCanvas, 515, 325, "Queue", headerStyle, UIPrimary) # Show some data addTextWithStyle(myCanvas, 15, 40, ("Turn " + str(currentTurn)), boldStyle, bl ack) addText(myCanvas, 15, 75, ("Workers: " + str(playerWorkers)), black) addText(myCanvas, 15, 90, ("Marines: " + str(playerMarines)), black) addText(myCanvas, 15, 105, ("Money: " + str(playerMoney)), black) addText(myCanvas, 15, 120, ("Income: " + str((playerWorkers * 50)) + " per tur n"), black) # make it into an image repaint(myCanvas) JOptionPane.showMessageDialog(None, "This is a message.") changePlayerWorkers(9) nextTurn()