def play_test_case(radius, cat_angle, mouse_angle):
    m, c = make_test_case(radius, cat_angle, mouse_angle)
    s = m.statue
    tk = Tk()
    arena = Arena (tk, meter*10, meter*10)
    arena.add(s)
    arena.add(c)
    arena.add(m)
    arena.pack()
    tk.mainloop()
Exemple #2
0
def rungame(catRadius, catAngle, mouseAngle):
    tk = Tk()  # Create a Tk top-level widget
    arena = Arena(tk)  # Create an Arena widget, arena
    arena.pack()  # Tell arena to pack itself on screen
    # arena.add(Turtle(Vector(200,200), 0))  # Add a very simple, basic turtle
    # arena.add(WalkingTurtle(Vector(300,300), 90, 0.5, arena))
    statue = Statue(Vector(300, 300))
    arena.add(statue)
    mouse = Mouse(mouseAngle, statue)
    arena.add(mouse)
    catRadius = catRadius * scalar
    cat = Cat(catAngle, catRadius, mouse, statue, arena)
    arena.add(cat)
    tk.mainloop()  # Enter the Tkinter event loop
Exemple #3
0
def runGame(catRadius, catAngle, mouseAngle):
	"""
	Main function that organizes and runs the game. Creates statue, mouse, and cat and adds them to the area.
	"""
	tk = Tk()                              # Create a Tk top-level widget
	arena = Arena(tk)                      # Create an Arena widget, arena
	arena.pack()                           # Tell arena to pack itself on screen

	statueObj = Statue(Vector(200,200))	   # Create statue at 200,200
	arena.add(statueObj)				   # Add statue to arena

	mouseObj = Mouse(mouseAngle, statueObj)	# Create mouse with statue passed as argument
	arena.add(mouseObj)						# Add mouse to arena

	cat_radius_scaled = catRadius * scale_factor		# Scale the radius of the cat to pixels
	catObj = Cat(catAngle, cat_radius_scaled, mouseObj)	# Create cat with mouse passed as argument
	arena.add(catObj)									# Add cat to arena

	arena.setLabels() # added (set labels to starting position)
	tk.mainloop()                          # Enter the Tkinter event loop
Exemple #4
0
def runGame(catRadius, catAngle, mouseAngle):
    """
	Main function that organizes and runs the game. Creates statue, mouse, and cat and adds them to the area.
	"""
    tk = Tk()  # Create a Tk top-level widget
    arena = Arena(tk)  # Create an Arena widget, arena
    arena.pack()  # Tell arena to pack itself on screen

    statueObj = Statue(Vector(200, 200))  # Create statue at 200,200
    arena.add(statueObj)  # Add statue to arena

    mouseObj = Mouse(mouseAngle,
                     statueObj)  # Create mouse with statue passed as argument
    arena.add(mouseObj)  # Add mouse to arena

    cat_radius_scaled = catRadius * scale_factor  # Scale the radius of the cat to pixels
    catObj = Cat(catAngle, cat_radius_scaled,
                 mouseObj)  # Create cat with mouse passed as argument
    arena.add(catObj)  # Add cat to arena

    arena.setLabels()  # added (set labels to starting position)
    tk.mainloop()  # Enter the Tkinter event loop
Exemple #5
0
Created on Sun Nov 18 15:44:25 2018

@author: Morten
"""

from tkinter import *  # Import everything from Tkinter
from Arena import Arena  # Import our Arena
from Turtle import Turtle  # Import our Turtle
from Vector import *  # Import everything from our Vector
from Statue import Statue
from Mouse import Mouse
from Cat import Cat
from globalVariables import *

statueRadius = 1
statuePosition = Vector(200, 200)
mouseAngle = -57.0
catAngle = 0.0
catRadius = 4.0

tk = Tk()  # Create a Tk top-level widget
arena = Arena(tk)  # Create an Arena widget, arena
arena.pack()  # Tell arena to pack itself on screen
s = Statue(statuePosition,
           statueRadius)  # Add a turtle at (200,200) heading 0=up
m = Mouse(statue=s, angle=mouseAngle, arena=arena)
c = Cat(arena=arena, mouse=m, angle=catAngle, radius=catRadius)
arena.add(s)
arena.add(m)
arena.add(c)
tk.mainloop()
from Tkinter import *                  # Import everything from Tkinter
from Arena   import Arena              # Import our Arena
from Turtle  import Turtle             # Import our Turtle
from Vector  import *                  # Import everything from our Vector

tk = Tk()                              # Create a Tk top-level widget
arena = Arena(tk)                      # Create an Arena widget, arena
arena.pack()                           # Tell arena to pack itself on screen
arena.add(Turtle(Vector(200,200), 0))  # Add a very simple, basic turtle
tk.mainloop()                          # Enter the Tkinter event loop
Exemple #7
0
'''Listen to SCOP streams for commands and render some turtles.'''

from Tkinter import *
from Arena import Arena
from WalkingTurtle import WalkingTurtle
from Vector import *
import scop
import os

scopserver = os.getenv("SCOPCTRLSERVER", "www.srcf.ucam.org")

sock1 = scop.scop_open(scopserver, "viewp1")
sock2 = scop.scop_open(scopserver, "viewp2")

scop.scop_listen(sock1, "p1ctrl")
scop.scop_listen(sock2, "p2ctrl")

tk = Tk()
arena = Arena(tk, sock1, sock2)
arena.pack()
arena.add(WalkingTurtle(Vector(200, 300), 0, 1, fill='turquoise'))
arena.add(WalkingTurtle(Vector(600, 300), 0, 1, fill='purple'))
tk.mainloop()
Exemple #8
0
# def setUpTest(cat_angle, mouse_angle, cat_radius):
#     """ Sets up testing environment for program, using cat_angle, mouse_angle, and cat_radius."""
#     tk = Tk()                              # Create a Tk top-level widget
#     arena = Arena(tk, width = 1000, height = 700)                      # Create an Arena widget, arena
#     arena.pack()
#     statue = Circle(Vector(200, 200), 0, radius = 1)
#     mouse = Mouse(statue.position + unit(statue.heading + mouse_angle) * statue.radius * statue.scale, speed = 1, orbit = statue, debug_flag = True, degree = mouse_angle)
#     cat = Cat(statue.position + unit(statue.heading + cat_angle) * (statue.radius + cat_radius) * statue.scale, speed = 1, orbit = statue, mouse = mouse, arena = arena, radius = statue.radius + cat_radius, debug_flag = True, degree = cat_angle)
#     doctest.testmod(extraglobs={'test_statue': statue, 'test_mouse': mouse, 'test_cat': cat})


if __name__ == "__main__":
    tk = Tk()  # Create a Tk top-level widget
    arena = Arena(tk, width=1000, height=700)  # Create an Arena widget, arena
    arena.pack()
    statue = Circle(Vector(200, 200), 0, radius=1)
    mouse = Mouse(
        statue.position + mouse_start * statue.radius * statue.scale, speed=1, orbit=statue, debug_flag=True, degree=0
    )
    cat = Cat(
        statue.position + unit(statue.heading + 270) * (statue.radius + 1) * statue.scale,
        speed=1,
        orbit=statue,
        mouse=mouse,
        arena=arena,
        radius=statue.radius + 1,
        debug_flag=True,
        degree=270,
    )
    doctest.testmod(extraglobs={"test_statue": statue, "test_mouse": mouse, "test_cat": cat})