Esempio n. 1
0

class DragScript(Script):
	def onMouseDrag(self, x, y, dx, dy, buttons, modifiers):
		self.gameObject.transform.position += (dx, dy)


class MyGameObject(GameObject):
	def __init__(self):
		super().__init__()

		self.addComponent(SpriteRenderer).setImage(image)
		self.addComponent(Input).size = (256, 256)
		self.addScript(DragScript)

camera = Camera()
camera.windowPosition = (0, 0)
camera.size = (400, 300)
camera.zoom = 0.3

# class MoveCamera(Script):
# 	def onMouseDrag(self, x, y, dx, dy, buttons, modifiers):
# 		self.gameObject.transform.position -= (dx, dy)
#
# input = camera.addComponent(Input)
# input.size = camera.size / camera.zoom
# camera.addScript(MoveCamera)

camera = Camera()
camera.windowPosition = (400, 0)
camera.size = (400, 300)
Esempio n. 2
0
from pyglet.sprite import pyglet

from gameengine.components.Physics import Physics
from gameengine.components.SpriteRenderer import SpriteRenderer
from gameengine.core.Camera import Camera
from gameengine.core.GameObject import GameObject
from gameengine.core.World import World

image = pyglet.image.load("image.png")
image.anchor_x = image.width // 2
image.anchor_y = image.height // 2

World.init("physics", True, 800, 600)

class MyGameObject(GameObject):
	def __init__(self):
		super().__init__()

		self.addComponent(SpriteRenderer).setImage(image)
		self.addComponent(Physics).addAcceleration((100, 400))


World.instantiate(MyGameObject, (400, 300))

Camera()

World.run()
Esempio n. 3
0
 def __init__(self):
     self.mainCamera = Camera()
     self.mainCamera.scene = self
     self.mainCamera.windowRect.size = Vector2(World.display.get_size())
     self.mainCamera.transform.size = Vector2(World.display.get_size())
Esempio n. 4
0
from gameengine.components.Input import Input
from gameengine.components.SpriteRenderer import SpriteRenderer
from gameengine.components.Label import Label
from gameengine.core.Camera import Camera
from gameengine.core.GameObject import GameObject
from gameengine.core.Script import Script
from gameengine.core.World import World

World.init("textRenderer", True, 800, 600)

image = pyglet.image.load("image.png")
# image.anchor_x = image.width // 2
# image.anchor_y = image.height // 2

c = Camera()
# c.transform.position = (200, 200)
c.zoom = 3


class MyGameObject(Label):
    def __init__(self):
        super().__init__()

        sr = self.addComponent(SpriteRenderer)
        sr.setImage(image)

        ip = self.addComponent(Input)
        ip.size = sr.size
        self.addScript(self.DragScript)