예제 #1
0
"""Example of the punch effect."""
import math
from wasabi2d import run, Scene, event, keys


scene = Scene()
scene.background = (1, 1, 1)

logo = scene.layers[0].add_sprite(
    'wasabi2d',
    pos=(scene.width / 2, scene.height / 2),
)
effect = scene.layers[0].set_effect(
    'dropshadow',
    radius=10,
    opacity=0.5
)


@event
def update(t):
    phase = math.sin(t) ** 2
    effect.radius = 20 * phase
    effect.offset = (20 * phase + 2,) * 2


@event
def on_key_down(key, mod):
    if key == keys.F12:
        scene.screenshot()
예제 #2
0
파일: memory.py 프로젝트: tjguk/wasabi2d
#       Configure window size according to COLS and ROWS
#
from wasabi2d import animate, clock, event, mouse, run, Scene
from wasabi2d.actor import Actor
from wasabi2d.tone import play

from functools import partial
import random
import time

scene = Scene(
    width=800,
    height=600,
    title='Memory',
)
scene.background = (.7, .7, .7)
scene.layers[1].set_effect('dropshadow', opacity=2)

COLS = 4
ROWS = 3
IMSIZE = 200
STATUS = []  # cells that have been clicked on
ignore = []  # cells that have been matches and are no longer in play

# Create two of each card image, then randomize before creating the board
START_IMAGES = ["im" + str(i + 1) for i in range(COLS * ROWS // 2)] * 2
random.shuffle(START_IMAGES)

STATUS = []

import math
from wasabi2d import Scene, run, event
from random import uniform as fraction
from random import randint as integer
from random import choice

scene = Scene(1300, 800)
scene.background = 'black'
photo = scene.layers[0].add_sprite(
    'diwali',
    pos=(scene.width / 2, scene.height / 2),
)

screen = scene.layers[0]
screen.set_effect('bloom', radius=50, intensity=0.9)

items = []
words = ['Happy', ' Diwali', ' ']

W = scene.width
H = scene.height


@event
def on_mouse_move(pos, rel):
    dx, dy = rel
    r = math.sqrt((dx**4) + (dy**4))
    pos = (integer(0, W), integer(0, H))

    c = screen.add_circle(radius=r, pos=pos, color=random_color())
    items.append(c)
예제 #4
0
import math
from wasabi2d import event, run, sounds, Scene, Vector2, clock, animate
import pygame

scene = Scene(antialias=8)
scene.background = (0, 0.03, 0.1)

ship = scene.layers[2].add_sprite('ship',
                                  pos=(scene.width / 2, scene.height / 2))
circ = scene.layers[0].add_circle(
    radius=30,
    pos=(100, 100),
    color='cyan',
    fill=False,
    stroke_width=3.0,
)
star = scene.layers[0].add_star(points=6,
                                inner_radius=30,
                                outer_radius=60,
                                pos=(400, 100),
                                color='yellow')
scene.layers[0].add_circle(
    radius=60,
    pos=(480, 120),
    color='#ff000088',
)
lbl = scene.layers[0].add_label("Time: 0s",
                                font='bubblegum_sans',
                                pos=(scene.width * 0.5, 560),
                                align='right')
lbl.color = 'yellow'
예제 #5
0
import sys
import numpy as np
import atexit
import json
from wasabi2d import Scene, event, run, keys, Vector2, mouse
from ascend.triangle_intersect import polygon_collision
from pygame import joystick, Rect
from scipy.spatial import ConvexHull

file = sys.argv[1]
datafile = f'ascend/walldata/{file}-walls.json'
scene = Scene(rootdir='ascend', width=350, height=720)
scene.background = (0.2, ) * 3

for suffix in ('-floor', '-wall'):
    scene.layers[-1].add_sprite(file + suffix,
                                pos=(scene.width / 2, scene.height / 2))
scene.layers[0].set_effect('dropshadow', radius=1)


def convex_hull(points):
    return points[ConvexHull(points).vertices].copy()


class Poly:
    def __init__(self):
        self.points = np.zeros((0, 2))
        self.handles = []
        self.shape = None

    def add_point(self, pos):
예제 #6
0
import math
from wasabi2d import Scene, run, event
from random import uniform as fraction
from random import randint as integer
from random import choice

scene = Scene(1300, 800)
scene.background = 'white'

photo = scene.layers[0].add_sprite(
    'dony stark',
    color='purple',
    pos=(scene.width / 2, scene.height / 2),
)
photo.scale = min(scene.width / photo.width, scene.height / photo.height)

screen = scene.layers[0]
screen.set_effect('bloom', radius=50, intensity=0.9)

items = []
words = ['Happy', 'Birthday ', 'IronMan', 'Love You 3000']

W = scene.width
H = scene.height


@event
def on_mouse_move(pos, rel):
    dx, dy = rel
    r = math.sqrt((dx**4) + (dy**4))
    pos = (integer(0, W), integer(0, H))
예제 #7
0
import math
from wasabi2d import Scene, run, event
from random import uniform as fraction
from random import randint as integer
from random import choice

scene = Scene(800,600)
scene.background = 'red'
photo = scene.layers[0].add_sprite(
    'diwali.png',
    pos=(scene.width / 2, scene.height / 2),
)

screen = scene.layers[1]
screen.set_effect('bloom', radius=60, intensity=1.2)

items = []
words = [ 'Happy',' Diwali',]

W = scene.width
H = scene.height

@event
def on_mouse_move(pos, rel):
    dx, dy = rel
    r = math.sqrt( (dx**4)+(dy**4) )
    pos=(integer(0, W), integer(0, H))
    
    c = screen.add_circle( radius=r, pos=pos, color=random_color() )
    items.append(c)