Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pvcraven/arcade
Browse files Browse the repository at this point in the history
  • Loading branch information
pvcraven committed Apr 24, 2017
2 parents 4af41db + 0dd8c47 commit 9396850
Show file tree
Hide file tree
Showing 25 changed files with 380 additions and 170 deletions.
11 changes: 5 additions & 6 deletions arcade/geometry.py
Expand Up @@ -7,10 +7,9 @@
from typing import List
from arcade.arcade_types import PointList

import math

PRECISION = 2


def are_polygons_intersecting(poly_a: PointList,
poly_b: PointList) -> bool:
"""
Expand Down Expand Up @@ -53,17 +52,17 @@ def are_polygons_intersecting(poly_a: PointList,
for poly in poly_a:
projected = normal[0] * poly[0] + normal[1] * poly[1]

if min_a == None or projected < min_a:
if min_a is None or projected < min_a:
min_a = projected
if max_a == None or projected > max_a:
if max_a is None or projected > max_a:
max_a = projected

for poly in poly_b:
projected = normal[0] * poly[0] + normal[1] * poly[1]

if min_b == None or projected < min_b:
if min_b is None or projected < min_b:
min_b = projected
if max_b == None or projected > max_b:
if max_b is None or projected > max_b:
max_b = projected

if max_a <= min_b or max_b <= min_a:
Expand Down
4 changes: 2 additions & 2 deletions arcade/joysticks.py
@@ -1,5 +1,5 @@
import pyglet.input

def get_joysticks():
return pyglet.input.get_joysticks()

def get_joysticks():
return pyglet.input.get_joysticks()
1 change: 0 additions & 1 deletion arcade/physics_engines.py
Expand Up @@ -151,7 +151,6 @@ def update(self):
self.player_sprite.center_y = round(self.player_sprite.center_y, 2)
# print(f"Spot Q ({self.player_sprite.center_x}, {self.player_sprite.center_y})")


# --- Move in the x direction
self.player_sprite.center_x += self.player_sprite.change_x

Expand Down
8 changes: 4 additions & 4 deletions arcade/sound.py
Expand Up @@ -7,10 +7,10 @@
import pyglet
import typing

pyglet.lib.load_library('C:/Program Files/Python36/Lib/site-packages/arcade/Win32/avbin')
pyglet.have_avbin=True
pyglet.debug_lib=True
pyglet.debug_trace=True
# pyglet.lib.load_library('C:/Program Files/Python36/Lib/site-packages/arcade/Win32/avbin')
# pyglet.have_avbin=True
# pyglet.debug_lib=True
# pyglet.debug_trace=True


def load_sound_library():
Expand Down
12 changes: 5 additions & 7 deletions arcade/sprite.py
Expand Up @@ -703,19 +703,19 @@ def update_animation(self):

if self.state == FACE_LEFT:
texture_list = self.walk_left_textures
if texture_list == None or len(texture_list) == 0:
if texture_list is None or len(texture_list) == 0:
raise RuntimeError("update_animation was called on a sprite that doesn't have a list of walk left textures.")
elif self.state == FACE_RIGHT:
texture_list = self.walk_right_textures
if texture_list == None or len(texture_list) == 0:
if texture_list is None or len(texture_list) == 0:
raise RuntimeError("update_animation was called on a sprite that doesn't have a list of walk right textures.")
elif self.state == FACE_UP:
texture_list = self.walk_up_textures
if texture_list == None or len(texture_list) == 0:
if texture_list is None or len(texture_list) == 0:
raise RuntimeError("update_animation was called on a sprite that doesn't have a list of walk up textures.")
elif self.state == FACE_DOWN:
texture_list = self.walk_down_textures
if texture_list == None or len(texture_list) == 0:
if texture_list is None or len(texture_list) == 0:
raise RuntimeError(
"update_animation was called on a sprite that doesn't have a list of walk down textures.")

Expand Down Expand Up @@ -814,7 +814,6 @@ def _create_rects(rect_list: Iterable[Sprite]) -> List[float]:

return v2f


def _render_rect_filled(offset: int, texture_id: str,
texture_coord_vbo: gl.GLuint, batch_count):
"""
Expand Down Expand Up @@ -845,7 +844,7 @@ def _draw_rects(shape_list: Iterable[Sprite], vertex_vbo_id: gl.GLuint,

gl.glEnable(gl.GL_BLEND)
gl.glBlendFunc(gl.GL_SRC_ALPHA, gl.GL_ONE_MINUS_SRC_ALPHA)
gl.glEnable(gl.GL_TEXTURE_2D) # As soon as this happens, can't use drawing commands
gl.glEnable(gl.GL_TEXTURE_2D) # As soon as this happens, can't use drawing commands
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_S, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameteri(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_WRAP_T, gl.GL_CLAMP_TO_EDGE)
gl.glTexParameterf(gl.GL_TEXTURE_2D, gl.GL_TEXTURE_MIN_FILTER, gl.GL_NEAREST)
Expand Down Expand Up @@ -907,5 +906,4 @@ def _draw_rects(shape_list: Iterable[Sprite], vertex_vbo_id: gl.GLuint,
texture_coord_vbo_id,
batch_count)


gl.glDisable(gl.GL_TEXTURE_2D)
Binary file added doc/examples/asteroid_smasher.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 0 additions & 3 deletions doc/examples/examples_to_do.rst
Expand Up @@ -5,7 +5,6 @@ These are examples we need, that haven't been created.

- Show how to do 'levels' based on list length hitting 0
- Show how to do 'levels' based on timer
- Text rotate
- Animating snow
- Move game controller
- Joystick calls
Expand All @@ -16,10 +15,8 @@ These are examples we need, that haven't been created.
- Destroy all sprites with a property
- See if there are any sprites with a property
- See if all items have a property
- Move sprite with game controller
- Pong
- Centipede
- Move between rooms
- Physics engine
- Enemies that shoot randomly
- Enemies that follow the user
21 changes: 21 additions & 0 deletions doc/examples/index.rst
Expand Up @@ -171,6 +171,22 @@ Bullets

:ref:`sprite_bullets_aimed`

.. figure:: thumbs/sprite_bullets_periodic.png
:figwidth: 170px

:ref:`sprite_bullets_periodic`

.. figure:: thumbs/sprite_bullets_random.png
:figwidth: 170px

:ref:`sprite_bullets_random`

.. figure:: thumbs/sprite_bullets_enemy_aims.png
:figwidth: 170px

:ref:`sprite_bullets_enemy_aims`


Platformers
^^^^^^^^^^^

Expand Down Expand Up @@ -235,6 +251,11 @@ Other

:ref:`asteroid_smasher`

.. figure:: thumbs/instruction_and_game_over_screens.png
:figwidth: 170px

:ref:`instruction_and_game_over_screens`




Expand Down
Binary file added doc/examples/sprite_bullets_enemy_aims.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions doc/examples/sprite_bullets_enemy_aims.rst
@@ -0,0 +1,16 @@
:orphan:

.. _sprite_bullets_enemy_aims:

Have Enemies Aim at Player
==========================

.. image:: sprite_bullets_enemy_aims.png
:width: 600px
:height: 600px
:align: center
:alt: Screen shot of using sprites to shoot things

.. literalinclude:: ../../examples/sprite_bullets_enemy_aims.py
:caption: sprite_bullets_enemy_aims.py
:linenos:
Binary file added doc/examples/sprite_bullets_periodic.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions doc/examples/sprite_bullets_periodic.rst
@@ -0,0 +1,16 @@
:orphan:

.. _sprite_bullets_periodic:

Have Enemies Periodically Shoot
===============================

.. image:: sprite_bullets_periodic.png
:width: 600px
:height: 600px
:align: center
:alt: Screenshot of using sprites to shoot things

.. literalinclude:: ../../examples/sprite_bullets_periodic.py
:caption: sprite_bullets_periodic.py
:linenos:
Binary file added doc/examples/sprite_bullets_random.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 16 additions & 0 deletions doc/examples/sprite_bullets_random.rst
@@ -0,0 +1,16 @@
:orphan:

.. _sprite_bullets_random:

Have Enemies Randomly Shoot
===========================

.. image:: sprite_bullets_random.png
:width: 600px
:height: 600px
:align: center
:alt: Screenshot of using sprites to shoot things

.. literalinclude:: ../../examples/sprite_bullets_random.py
:caption: sprite_bullets_random.py
:linenos:
2 changes: 1 addition & 1 deletion doc/examples/update_thumbnails.bat
@@ -1 +1 @@
mogrify -resize 200x200 -extent 200x200 -background transparent -path thumbs *.png
mogrify -resize 200x158 -extent 200x158 -background transparent -path thumbs *.png
10 changes: 2 additions & 8 deletions examples/asteroid_smasher.py
Expand Up @@ -10,9 +10,9 @@
import math
import arcade

SCALE = 1
SCALE = 0.5
OFFSCREEN_SPACE = 300
SCREEN_WIDTH = 1024
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
LEFT_LIMIT = -OFFSCREEN_SPACE
RIGHT_LIMIT = SCREEN_WIDTH + OFFSCREEN_SPACE
Expand Down Expand Up @@ -109,16 +109,12 @@ def update(self):
super().update()
if self.center_x < LEFT_LIMIT:
self.center_x = RIGHT_LIMIT
print("Left")
if self.center_x > RIGHT_LIMIT:
self.center_x = LEFT_LIMIT
print("Right")
if self.center_y > TOP_LIMIT:
self.center_y = BOTTOM_LIMIT
print("Bottom")
if self.center_y < BOTTOM_LIMIT:
self.center_y = TOP_LIMIT
print("Top")


class BulletSprite(TurningSprite):
Expand Down Expand Up @@ -339,8 +335,6 @@ def animate(self, x):
""" Move everything """

self.frame_count += 1
if self.frame_count % 60 == 0:
print(self.frame_count)

if not self.game_over:
self.all_sprites_list.update()
Expand Down
130 changes: 0 additions & 130 deletions examples/basketball.py

This file was deleted.

Binary file added examples/images/playerShip1_green.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 0 additions & 2 deletions examples/platformer.py
@@ -1,5 +1,3 @@
import random
import math
import arcade
import copy

Expand Down

0 comments on commit 9396850

Please sign in to comment.