Created
December 13, 2021 23:13
-
-
Save sgodycki/8040e5ba6bf344cb7efa6e51cd0042db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from network import * | |
id = "rory1" | |
x = 570 | |
y = 700 | |
SpX = 0 | |
SpY = 200 | |
SpD = 10 | |
SpW = 300 | |
SpH = 300 | |
#poop x,y,direction | |
QpX = 200 | |
QpY = 240 | |
QpD = 1 | |
puppyW = 300 | |
puppyH = 300 | |
position = 0 | |
startTime = 0 | |
def setup(): | |
size(800,800) | |
rectMode(CENTER) | |
global puppyX | |
puppyX = 0 | |
global puppyY | |
puppyY = 0 | |
global puppy | |
puppy = loadImage("doggg.png") | |
global puppy2 | |
puppy2 = loadImage("doggg2.png") | |
global lvl1 | |
lvl1 = loadImage("grass background.png") | |
global lvl2 | |
lvl2 = loadImage("grass background2.png") | |
global level | |
level = 1 | |
global shrub | |
shrub = loadImage("shrub.png") | |
global poop | |
poop = loadImage("poop.png") | |
global win | |
win = loadImage("youwon.png") | |
global toy | |
toy = loadImage("puppy toy.png") | |
def level1(): | |
global lvl1, puppy, puppyX, puppyY, puppyW, puppyH,startTime | |
global level, shrub, SpX, SpY, SpD, SpW, SpH | |
image(lvl1, 0, 0) | |
image(puppy, puppyX-70, puppyY-60, puppyW, puppyH) | |
image(shrub, SpX, SpY, SpW, SpH) | |
# move the shrub for a while then stop | |
if millis() > startTime and millis() < startTime + 2000: | |
SpX = SpX + 1 | |
# resetting StartTime variable | |
# timing starts over: | |
if millis() > startTime + 4000: | |
startTime = millis() | |
if puppyY > 700: | |
level = 2 | |
def level2(): | |
global lvl1, puppy, level, puppy, puppyX, puppyY, puppyW, startTime | |
global puppyH, QpX, QpY, QpD, poop, toy, SpX,SpY,SpW,SpH | |
image(lvl1, 0, 0) | |
image(toy, 0,0) | |
image(puppy, puppyX + 200, puppyY - 900, puppyW, puppyH) | |
image(poop, QpX, QpY, 300, 300) | |
#poop movement | |
QpX = QpX + QpD | |
if QpX > width: | |
QpD = -1 | |
#win screen | |
if puppyY > 1400: | |
image(win, 0,0) | |
def draw(): | |
global level, puppyX, puppyY | |
if level == 1: | |
level1() | |
if level == 2: | |
level2() | |
queryDictionary = { "id":id, "SpX":SpX, "SpY":SpY, "SpD":SpD, "SpW":SpW, "SpH":SpH, | |
"QpX":QpX, "QpY":QpY,"QpD":QpD, "puppyW":puppyW, "puppyH":puppyH, | |
"position":position, "startTime":startTime } | |
itemList = sendData(queryDictionary) | |
i = 0 | |
while i < len(itemList): | |
item = itemList[i] | |
ellipse(item["x"],item["y"],25,25) | |
i = i + 1 | |
def keyPressed(): | |
global puppyX,puppyY | |
if key == 'q': | |
puppyX = puppyX +5 # right movement | |
if key == 'w': | |
puppyX = puppyX -5 #left movement | |
if key == 'j': | |
puppyY = puppyY -5 #upward movement | |
if key == 'l': | |
puppyY = puppyY +5 #downward movement |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
import json | |
lastSend = 0 | |
def sendData(d): | |
global lastSend | |
responseList = [] | |
# only send once per second | |
if millis() > lastSend + 1000: | |
lastSend = millis() | |
queryString = "id=" + d["id"] | |
queryString += "&x=" + str(d["x"]) | |
queryString += "&y=" + str(d["y"]) | |
response = urllib2.urlopen('http://127.0.0.1:8000/cgi-bin/server.py?'+queryString) | |
j = json.load(response) | |
for id in j: | |
c = {} | |
c["id"] = id | |
item = j[id] | |
c["x"] = int(item["x"]) | |
c["y"] = int(item["y"]) | |
responseList.append(c) | |
return responseList |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mode=Python | |
mode.id=jycessing.mode.PythonMode |
Hi Sasha.
You need to give me more to work with than that. What exactly are you doing and what is the error or other unexpected behavior that you are seeing?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@rors I don't understand why my code isn't running