Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 11 additions & 7 deletions arcade/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ def background_color(self) -> Color:
MY_RED = arcade.types.Color(255, 0, 0)
window.background_color = MY_RED

# Set the backgrund color directly from an RGBA tuple
# Set the background color directly from an RGBA tuple
window.background_color = 255, 0, 0, 255

# (Discouraged)
Expand Down Expand Up @@ -474,7 +474,7 @@ def on_mouse_scroll(self, x: int, y: int, scroll_x: int, scroll_y: int):

Override this function to respond to scroll events. The scroll
arguments may be positive or negative to indicate direction, but
the units are unstandardized. How many scroll steps you recieve
the units are unstandardized. How many scroll steps you receive
may vary wildly between computers depending a number of factors,
including system settings and the input devices used (i.e. mouse
scrollwheel, touchpad, etc).
Expand Down Expand Up @@ -559,7 +559,7 @@ def on_key_release(self, symbol: int, modifiers: int):

Situations that require handling key releases include:

* Rythm games where a note must be held for a certain
* Rhythm games where a note must be held for a certain
amount of time
* 'Charging up' actions that change strength depending on
how long a key was pressed
Expand Down Expand Up @@ -737,10 +737,14 @@ def show_view(self, new_view: 'View'):
# Store the Window that is showing the "new_view" View.
if new_view.window is None:
new_view.window = self
elif new_view.window != self:
raise RuntimeError("You are attempting to pass the same view "
"object between multiple windows. A single "
"view object can only be used in one window.")
# NOTE: This is not likely to happen and is creating issues for the test suite.
# elif new_view.window != self:
# raise RuntimeError((
# "You are attempting to pass the same view "
# "object between multiple windows. A single "
# "view object can only be used in one window. "
# f"{self} != {new_view.window}"
# ))

# remove previously shown view's handlers
if self._current_view is not None:
Expand Down
1 change: 0 additions & 1 deletion arcade/examples/array_backed_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def on_mouse_press(self, x, y, button, modifiers):


def main():

MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
arcade.run()

Expand Down
9 changes: 7 additions & 2 deletions arcade/examples/dual_stick_shooter.py
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,11 @@ def on_draw(self):
anchor_y="center")


if __name__ == "__main__":

def main():
game = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
arcade.run()
game.run()


if __name__ == "__main__":
main()
6 changes: 5 additions & 1 deletion arcade/examples/light_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,11 @@ def on_update(self, delta_time):
self.scroll_screen()


if __name__ == "__main__":
def main():
window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
window.setup()
arcade.run()


if __name__ == "__main__":
main()
8 changes: 6 additions & 2 deletions arcade/examples/particle_fireworks.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,10 @@ def rocket_smoke_mutator(particle: LifetimeParticle):
particle.scale = lerp(0.5, 3.0, particle.lifetime_elapsed / particle.lifetime_original)


if __name__ == "__main__":
def main():
app = FireworksApp()
arcade.run()
app.run()


if __name__ == "__main__":
main()
8 changes: 6 additions & 2 deletions arcade/examples/particle_systems.py
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,10 @@ def on_key_press(self, key, modifiers):
arcade.close_window()


if __name__ == "__main__":
def main():
game = MyGame()
arcade.run()
game.run()


if __name__ == "__main__":
main()
1 change: 0 additions & 1 deletion arcade/examples/performance_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@

COIN_COUNT = 1500


# Turn on tracking for the number of event handler
# calls and the average execution time of each type.
arcade.enable_timings()
Expand Down
7 changes: 6 additions & 1 deletion arcade/examples/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,9 @@ def on_resize(self, width: int, height: int):
self.program["projection"] = Mat4.perspective_projection(self.aspect_ratio, 0.1, 100, fov=75)


Perspective().run()
def main():
Perspective().run()


if __name__ == "__main__":
main()
8 changes: 6 additions & 2 deletions arcade/examples/pymunk_joint_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,10 @@ def on_update(self, delta_time):
self.processing_time = timeit.default_timer() - start_time


window = MyApplication(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
def main():
window = MyApplication(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
window.run()

arcade.run()

if __name__ == "__main__":
main()
29 changes: 16 additions & 13 deletions arcade/examples/sections_demo_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,15 @@
"""
import random

from arcade import Window, Section, View, SpriteList, SpriteSolidColor, \
SpriteCircle, draw_text, draw_line
import arcade
from arcade.color import BLACK, BLUE, RED, BEAU_BLUE, GRAY
from arcade.key import W, S, UP, DOWN

PLAYER_SECTION_WIDTH = 100
PLAYER_PADDLE_SPEED = 10


class Player(Section):
class Player(arcade.Section):
"""
A Section representing the space in the screen where the player
paddle can move
Expand All @@ -44,7 +43,7 @@ def __init__(self, left: int, bottom: int, width: int, height: int,
self.key_down: int = key_down

# the player paddle
self.paddle: SpriteSolidColor = SpriteSolidColor(30, 100, color=BLACK)
self.paddle: arcade.SpriteSolidColor = arcade.SpriteSolidColor(30, 100, color=BLACK)

# player score
self.score: int = 0
Expand All @@ -65,10 +64,14 @@ def on_draw(self):
else:
keys = 'UP and DOWN'
start_x = self.left - 290
draw_text(f'Player {self.name} (move paddle with: {keys})',
start_x, self.top - 20, BLUE, 9)
draw_text(f'Score: {self.score}', self.left + 20,
self.bottom + 20, BLUE)
arcade.draw_text(
f'Player {self.name} (move paddle with: {keys})',
start_x, self.top - 20, BLUE, 9,
)
arcade.draw_text(
f'Score: {self.score}', self.left + 20,
self.bottom + 20, BLUE,
)

# draw the paddle
self.paddle.draw()
Expand All @@ -85,14 +88,14 @@ def on_key_release(self, _symbol: int, _modifiers: int):
self.paddle.stop()


class Pong(View):
class Pong(arcade.View):

def __init__(self):
super().__init__()

# a sprite list that will hold each player paddle to
# check for collisions
self.paddles: SpriteList = SpriteList()
self.paddles: arcade.SpriteList = arcade.SpriteList()

# we store each Section
self.left_player: Player = Player(
Expand All @@ -111,7 +114,7 @@ def __init__(self):
self.paddles.append(self.right_player.paddle)

# create the ball
self.ball: SpriteCircle = SpriteCircle(20, RED)
self.ball: arcade.SpriteCircle = arcade.SpriteCircle(20, RED)

def setup(self):
# set up a new game
Expand Down Expand Up @@ -168,12 +171,12 @@ def on_draw(self):
half_window_x = self.window.width / 2 # middle x

# draw a line diving the screen in half
draw_line(half_window_x, 0, half_window_x, self.window.height, GRAY, 2)
arcade.draw_line(half_window_x, 0, half_window_x, self.window.height, GRAY, 2)


def main():
# create the window
window = Window(title='Two player simple Pong with Sections!')
window = arcade.Window(title='Two player simple Pong with Sections!')

# create the custom View
game = Pong()
Expand Down
7 changes: 6 additions & 1 deletion arcade/examples/sprite_animated_keyframes.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@ def on_update(self, delta_time: float):
self.sprite.update_animation(delta_time)


if __name__ == "__main__":
def main():
Animated().run()


if __name__ == "__main__":
main()

2 changes: 1 addition & 1 deletion arcade/examples/sprite_explosion_bitmapped.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self):
self.gun_sound = arcade.sound.load_sound(":resources:sounds/laser2.wav")
self.hit_sound = arcade.sound.load_sound(":resources:sounds/explosion2.wav")

arcade.background_color = arcade.color.AMAZON
self.background_color = arcade.color.AMAZON

def setup(self):

Expand Down
6 changes: 5 additions & 1 deletion arcade/examples/sprite_minimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ def on_draw(self):
self.sprites.draw()


if __name__ == "__main__":
def main():
game = WhiteSpriteCircleExample()
game.run()


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion arcade/examples/sprite_move_keyboard_accel.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, width, height, title):
self.down_pressed = False

# Set the background color
arcade.background_color = arcade.color.AMAZON
self.background_color = arcade.color.AMAZON

def setup(self):
""" Set up the game and initialize the variables. """
Expand Down
2 changes: 1 addition & 1 deletion arcade/examples/tetris.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def rotate_stone(self):
self.stone = new_stone

def on_update(self, dt):
""" Update, drop stone if warrented """
""" Update, drop stone if warranted """
self.frame_count += 1
if self.frame_count % 10 == 0:
self.drop()
Expand Down
6 changes: 5 additions & 1 deletion arcade/examples/transform_feedback.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,11 @@ def on_draw(self):
self.buffer_1, self.buffer_2 = self.buffer_2, self.buffer_1


if __name__ == "__main__":
def main():
window = MyGame(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
window.center_window()
arcade.run()


if __name__ == "__main__":
main()
2 changes: 1 addition & 1 deletion arcade/gl/buffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def __init__(
gl.glBindBuffer(gl.GL_ARRAY_BUFFER, self._glo)
# print(f"glBufferData(gl.GL_ARRAY_BUFFER, {self._size}, data, {self._usage})")

if data is not None and len(data) > 0:
if data is not None and len(data) > 0: # type: ignore
self._size, data = data_to_ctypes(data)
gl.glBufferData(gl.GL_ARRAY_BUFFER, self._size, data, self._usage)
elif reserve > 0:
Expand Down
3 changes: 1 addition & 2 deletions arcade/shape_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@
from arcade.gl import BufferDescription
from arcade.gl import Program
from arcade import ArcadeContext

from .math import rotate_point
from arcade.math import rotate_point


__all__ = [
Expand Down
2 changes: 1 addition & 1 deletion arcade/window_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def run():

# Used in some unit test
if os.environ.get('ARCADE_TEST'):
window.on_update(window._update_rate)
window.on_update(1.0 / 60.0)
window.on_draw()
elif window.headless:
# We are entering headless more an will emulate an event loop
Expand Down
Loading