ic
authorFrank DeMarco <if.self.end@gmail.com>
Tue, 22 Jan 2019 04:36:20 +0000 (23:36 -0500)
committerFrank DeMarco <if.self.end@gmail.com>
Tue, 22 Jan 2019 04:36:20 +0000 (23:36 -0500)
.gitignore [new file with mode: 0644]
Mushroom.py [new file with mode: 0644]
README [new file with mode: 0644]
README.html [new file with mode: 0644]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..a170185
--- /dev/null
@@ -0,0 +1,2 @@
+local/
+mushroom.html
diff --git a/Mushroom.py b/Mushroom.py
new file mode 100644 (file)
index 0000000..8eb0a39
--- /dev/null
@@ -0,0 +1,279 @@
+import os, time, math
+
+ORIGIN = 294, 9
+
+def main():
+    callxdo("search flickgame\.org.* windowactivate")
+    settitle("Mushroom Train")
+    clickcolor(14)
+    fillpoint(200, 200)
+    left = 40
+    top = 20
+    for color in xrange(7, 13): 
+        clickcolor(color)
+        drawtitle(left, top)
+        left += 1
+        top += 1
+    for ii, offset in enumerate(xrange(0, 60, 20)):
+        activateframe(ii)
+        clickcolor(14)
+        fillpoint(200, 200)
+        drawtrain()
+        drawmushroom(offset)
+        setbranches(ii + 2)
+    activateframe(3)
+    clickcolor(14)
+    fillpoint(200, 200)
+    drawtrain()
+    setbranch(0, 5)
+    setbranch(3, 5)
+    setbranch(15, 5)
+    activateframe(4)
+    clickcolor(13)
+    fillpoint(200, 200)
+    clickcolor(14)
+    drawparty(20, 20)
+    # for ii in xrange(16):
+    #     activateframe(ii)
+    #     fillpoint(200, 200, ii)
+    #     if ii == 16:
+    #         setbranch(ii, 1)
+    #     else:
+    #         setbranch(ii, ii + 2)
+    save("mushroom")
+    time.sleep(1)
+    openflick("mushroom")
+    time.sleep(4)
+    clickx = 700
+    clicky = 550
+    callxdo("mousemove %i %i" % (clickx, clicky))
+    time.sleep(2)
+    callxdo("click 1")
+    for _ in xrange(2):
+        time.sleep(1)
+        callxdo("mousemove_relative 10 0")
+        time.sleep(1)
+        callxdo("click 1")
+    time.sleep(1)
+    callxdo("mousemove_relative 250 0")
+    time.sleep(1)
+    callxdo("click 1")
+
+def setbranches(index):
+    setbranch(0, index)
+    setbranch(4, index)
+    setbranch(6, index)
+    setbranch(15, index)
+
+def drawmushroom(offset):
+    clickcolor(4)
+    drawrectangle(200 + offset, 300, 100, 40)
+    clickcolor(6)
+    drawhalfcircle(250 + offset, 300, 110)
+    fillpoint(250 + offset, 300 - 20, True)
+    clickbrush(2)
+    clickcolor(15)
+    clickpoint(180 + offset, 280, canvas=True)
+    clickpoint(280 + offset, 240, canvas=True)
+    clickbrush(5)
+    clickpoint(200 + offset, 230, canvas=True)
+    clickpoint(310 + offset, 280, canvas=True)
+    clickbrush(2)
+    clickcolor(0)
+    clickpoint(215 + offset, 322, canvas=True)
+    clickpoint(285 + offset, 322, canvas=True)
+    drawrectangle(240 + offset, 328, 20, 6)
+
+def drawtrain():
+    clickbrush(1)
+    clickcolor(3)
+    drawrectangle(420, 260, 180, 75)
+    clickbrush(0)
+    clickcolor(15)
+    for x in xrange(430, 430 + 180, 37):
+        drawrectangle(x, 270, 14, 40, False)
+    clickbrush(3)
+    clickcolor(0)
+    clickpoint(440, 350, canvas=True)
+    clickpoint(580, 350, canvas=True)
+
+def drawhalfcircle(x, y, r):
+    clickbrush(2)
+    drawline((x - r, y), (x + r, y))
+    for angle in range(0, 90, 5) + range(270, 360, 5):
+        end = getendpoint((x, y), angle, r)
+        clickpoint(end[0], end[1], canvas=True)
+
+def getendpoint(start, angle, magnitude, translate_angle=True):
+    """clockwise, 0 is up"""
+    x0, y0 = start
+    dx, dy = getdelta(angle, magnitude, translate_angle)
+    return x0 + dx, y0 + dy
+
+def getdelta(angle, magnitude, translate_angle=True):
+    if translate_angle:
+        angle = math.radians(angle)
+    return math.sin(angle) * magnitude, -math.cos(angle) * magnitude
+
+def drawrectangle(left, top, width, height, fill=True):
+    clickbrush(0)
+    drawline((left, top), (left + width, top))
+    drawline((left + width, top), (left + width, top + height))
+    drawline((left, top + height), (left + width, top + height))
+    drawline((left, top), (left, top + height))
+    time.sleep(.2)
+    if fill:
+        fillpoint(left + (width / 2), top + (height / 2), True)
+
+def drawparty(left, top):
+    height = 400
+    width = 100
+    clickbrush(4)
+    drawline((left, top), (left, top + height))
+    drawline((left, top), (left + 100, top))
+    drawline((left + width, top), (left + width, top + height / 2))
+    drawline((left, top + height / 2), (left + width, top + height / 2))
+    left += 125
+    drawline((left, top), (left, top + height))
+    drawline((left, top), (left + width, top))
+    drawline((left + width, top), (left + width, top + height))
+    drawline((left, top + height / 2), (left + width, top + height / 2))
+    left += 125
+    drawline((left, top), (left, top + height))
+    drawline((left, top), (left + width, top))
+    drawline((left + width, top), (left + width, top + height / 2))
+    drawline((left, top + height / 2), (left + width, top + height / 2))
+    drawline((left, top + height / 2), (left + width, top + height))
+    left += 125
+    drawline((left, top), (left + width, top))
+    drawline((left + width / 2, top), (left + width / 2, top + height))
+    left += 125
+    drawline((left, top), (left + width / 2, top + height / 2))
+    drawline((left + width, top), (left + width / 2, top + height / 2))
+    drawline((left + width / 2, top + height / 2), (left + width / 2, top + height))
+
+def drawtitle(left, top):
+    height = 100
+    clickbrush(0)
+    drawm(left, top, height, 30)
+    drawline((left + 40, top), (left + 40, top + height))
+    drawline((left + 40, top + height), (left + 55, top + height))
+    drawline((left + 55, top), (left + 55, top + height))
+    drawline((left + 65, top), (left + 65, top + height / 2))
+    drawline((left + 65, top), (left + 85, top))
+    drawline((left + 65, top + height / 2), (left + 85, top + height / 2))
+    drawline((left + 85, top + height / 2), (left + 85, top + height))
+    drawline((left + 65, top + height), (left + 85, top + height))
+    drawline((left + 95, top), (left + 95, top + height))
+    drawline((left + 95, top + height / 2), (left + 115, top + height / 2))
+    drawline((left + 115, top), (left + 115, top + height))
+    drawline((left + 125, top), (left + 125, top + height))
+    drawline((left + 125, top), (left + 145, top))
+    drawline((left + 145, top), (left + 145, top + height / 2))
+    drawline((left + 125, top + height / 2), (left + 145, top + height / 2))
+    drawline((left + 125, top + height / 2), (left + 145, top + height))
+    drawo(left + 155, top, height)
+    drawo(left + 185, top, height)
+    drawm(left + 215, top, height, 30)
+
+def drawo(left, top, height):
+    drawline((left, top), (left + 20, top))
+    drawline((left, top), (left, top + height))
+    drawline((left + 20, top + height), (left, top + height))
+    drawline((left + 20, top + height), (left + 20, top))
+
+def drawm(left, top, height, offset):
+    drawline((left, top), (left, top + height))
+    drawline((left, top), (left + offset, top))
+    drawline((left + offset, top), (left + offset, top + height))
+    drawline((left + offset / 2, top), (left + offset / 2, top + height))
+
+def drawline(start, end):
+    gotopoint(start[0], start[1], True)
+    callxdo("mousedown 1")
+    gotopoint(end[0], end[1], True)
+    callxdo("mouseup 1")
+    time.sleep(.2)
+
+def clickbrush(index):
+    clickpoint(765, [386, 348, 307, 270, 233, 195, 156, 119][index])
+
+def save(name):
+    clickpoint(771, 39)
+    time.sleep(1)
+    typeword(name)
+    hitkey("Return", 2, 500)
+
+def openflick(name):
+    hitkey("ctrl+t")
+    time.sleep(1)
+    hitkey("F11")
+    time.sleep(1)
+    hitkey("ctrl+l")
+    time.sleep(1)
+    typeword("file:///home/frank/projects/public/games/mt/%s.html" % name)
+    hitkey("Return")
+    time.sleep(1)
+    hitkey("F11")
+
+def hitkey(name, repeat=1, delay=0):
+    callxdo("key --repeat %i --repeat-delay %i %s" % (repeat, delay, name))
+
+def settitle(title):
+    clickpoint(533, 26, 3)
+    hitkey("BackSpace")
+    typeword(title)
+
+def typeword(word):
+    for char in word:
+        if char == " ":
+            hitkey("space")
+        elif char == ":":
+            hitkey("colon")
+        elif char == "/":
+            hitkey("slash")
+        elif char == ".":
+            hitkey("period")
+        else:
+            hitkey(char)
+
+def clickpoint(x, y, repeat=1, canvas=False):
+    gotopoint(x, y, canvas)
+    callxdo("click --repeat %i 1" % repeat)
+
+def clickcolor(index):
+    clickpoint(135 + index * 38, 476)
+
+def setbranch(color, index):
+    clickpoint(135 + color * 38, 497)
+    # callxdo("key %s" % keystokeysequence(str(index)))
+    callxdo("key --repeat 16 Up")
+    callxdo("key --repeat %i Down" % index)
+    clickpoint(0, 0)
+
+def keystokeysequence(keys):
+    sequence = ""
+    for char in keys:
+        sequence += char + "+"
+    return sequence
+
+def fillpoint(x, y, canvas=False):
+    clickpoint(766, 421)
+    clickpoint(x, y, canvas=canvas)
+
+def activateframe(index):
+    clickpoint(19, 58 + index * 27)
+
+def gotopoint(x, y, canvas=False):
+    ax = ORIGIN[0] + x
+    ay = ORIGIN[1] + y
+    if canvas:
+        ax += 98
+        ay += 52
+    callxdo("mousemove %i %i" % (ax, ay))
+
+def callxdo(command):
+    os.system("xdotool %s" % command)
+
+if __name__ == "__main__":
+    main()
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..6bfb92f
--- /dev/null
+++ b/README
@@ -0,0 +1,44 @@
+Mushroom Train
+69696969696969
+
+This script generates and plays a game about a mushroom getting on a party
+train.  Made for Synchrony demo party 2019.
+
+
+Notes
+69696
+
+The code is platform dependent and doesn't find the flickgame interface on its
+own, but I'm posting it so others can build off the basic idea
+
+
+Prerequisites
+6969696969696
+
+- only runs on a Linux OS
+- Python (script was run with 2.7.9)
+- xdotool (http://www.semicomplete.com/projects/xdotool)
+- flickgame (runs in a browser at http://flickgame.org)
+- web browser (I used chromium)
+
+
+Run
+696
+
+- the ORIGIN coordinates should be aligned with the leftmost part of the
+  fullscreened flickgame interface (the edge of the white highlight on the
+  frame menu) and 9 pixels above the flickgame title box
+- make sure the hardcoded regex that contains the flickgame interface window
+  title works with the browser you're using
+- Browse to flickgame.org
+- put the browser in fullscreen with F11 (if this isn't the fullscreen button
+  for your browser, you'll have to edit the script)
+- run "python Mushroom.py"
+
+
+Contact
+6969696
+
+tw: @diskmem
+http://shampoo.ooo
+if.self.end at gmail.com
diff --git a/README.html b/README.html
new file mode 100644 (file)
index 0000000..7cbb76a
--- /dev/null
@@ -0,0 +1,57 @@
+
+<html>
+<head>
+<title>README</title>
+</head>
+<body>
+<pre>
+    
+Mushroom Train
+69696969696969
+
+This script generates and plays a game about a mushroom getting on a party
+train.  Made for Synchrony demo party 2019.
+
+
+Notes
+69696
+
+The code is platform dependent and doesn't find the flickgame interface on its
+own, but I'm posting it so others can build off the basic idea
+
+
+Prerequisites
+6969696969696
+
+- only runs on a Linux OS
+- Python (script was run with 2.7.9)
+- xdotool (http://www.semicomplete.com/projects/xdotool)
+- flickgame (runs in a browser at http://flickgame.org)
+- web browser (I used chromium)
+
+
+Run
+696
+
+- the ORIGIN coordinates should be aligned with the leftmost part of the
+  fullscreened flickgame interface (the edge of the white highlight on the
+  frame menu) and 9 pixels above the flickgame title box
+- make sure the hardcoded regex that contains the flickgame interface window
+  title works with the browser you're using
+- Browse to flickgame.org
+- put the browser in fullscreen with F11 (if this isn't the fullscreen button
+  for your browser, you'll have to edit the script)
+- run "python Mushroom.py"
+
+
+Contact
+6969696
+
+tw: @diskmem
+http://shampoo.ooo
+if.self.end at gmail.com
+
+</pre>
+</body>
+</html>
+