├── .gitignore ├── .idea ├── inspectionProfiles │ └── Project_Default.xml ├── misc.xml ├── modules.xml ├── rlzero.iml └── vcs.xml ├── LICENSE ├── MANIFEST.in ├── README.md ├── bin └── rlzrun ├── coords_demo.py ├── docs-src ├── Makefile ├── README.md ├── _build │ ├── doctrees │ │ ├── README.doctree │ │ ├── environment.pickle │ │ ├── examples.doctree │ │ ├── generated │ │ │ ├── rlzero.Actor.doctree │ │ │ ├── rlzero.Cube.doctree │ │ │ ├── rlzero.Gamepad.doctree │ │ │ ├── rlzero.Keyboard.doctree │ │ │ ├── rlzero.Mouse.doctree │ │ │ ├── rlzero.Shape.doctree │ │ │ ├── rlzero.Sound.doctree │ │ │ ├── rlzero.Sphere.doctree │ │ │ ├── rlzero.mouse.doctree │ │ │ └── rlzero.run.doctree │ │ ├── index.doctree │ │ ├── pyray.doctree │ │ ├── raylib.doctree │ │ └── rlzero.doctree │ └── html │ │ ├── .buildinfo │ │ ├── README.html │ │ ├── _sources │ │ ├── README.md.txt │ │ ├── examples.rst.txt │ │ ├── generated │ │ │ ├── rlzero.Actor.rst.txt │ │ │ ├── rlzero.Cube.rst.txt │ │ │ ├── rlzero.Gamepad.rst.txt │ │ │ ├── rlzero.Keyboard.rst.txt │ │ │ ├── rlzero.Mouse.rst.txt │ │ │ ├── rlzero.Shape.rst.txt │ │ │ ├── rlzero.Sound.rst.txt │ │ │ ├── rlzero.Sphere.rst.txt │ │ │ ├── rlzero.mouse.rst.txt │ │ │ └── rlzero.run.rst.txt │ │ ├── index.rst.txt │ │ ├── pyray.rst.txt │ │ ├── raylib.rst.txt │ │ └── rlzero.rst.txt │ │ ├── _static │ │ ├── basic.css │ │ ├── css │ │ │ ├── badge_only.css │ │ │ ├── fonts │ │ │ │ ├── Roboto-Slab-Bold.woff │ │ │ │ ├── Roboto-Slab-Bold.woff2 │ │ │ │ ├── Roboto-Slab-Regular.woff │ │ │ │ ├── Roboto-Slab-Regular.woff2 │ │ │ │ ├── fontawesome-webfont.eot │ │ │ │ ├── fontawesome-webfont.svg │ │ │ │ ├── fontawesome-webfont.ttf │ │ │ │ ├── fontawesome-webfont.woff │ │ │ │ ├── fontawesome-webfont.woff2 │ │ │ │ ├── lato-bold-italic.woff │ │ │ │ ├── lato-bold-italic.woff2 │ │ │ │ ├── lato-bold.woff │ │ │ │ ├── lato-bold.woff2 │ │ │ │ ├── lato-normal-italic.woff │ │ │ │ ├── lato-normal-italic.woff2 │ │ │ │ ├── lato-normal.woff │ │ │ │ └── lato-normal.woff2 │ │ │ └── theme.css │ │ ├── doctools.js │ │ ├── documentation_options.js │ │ ├── file.png │ │ ├── jquery-3.5.1.js │ │ ├── jquery.js │ │ ├── js │ │ │ ├── badge_only.js │ │ │ ├── html5shiv-printshiv.min.js │ │ │ ├── html5shiv.min.js │ │ │ └── theme.js │ │ ├── language_data.js │ │ ├── minus.png │ │ ├── plus.png │ │ ├── pygments.css │ │ ├── searchtools.js │ │ ├── underscore-1.13.1.js │ │ └── underscore.js │ │ ├── examples.html │ │ ├── generated │ │ ├── rlzero.Actor.html │ │ ├── rlzero.Cube.html │ │ ├── rlzero.Gamepad.html │ │ ├── rlzero.Keyboard.html │ │ ├── rlzero.Mouse.html │ │ ├── rlzero.Shape.html │ │ ├── rlzero.Sound.html │ │ ├── rlzero.Sphere.html │ │ ├── rlzero.mouse.html │ │ └── rlzero.run.html │ │ ├── genindex.html │ │ ├── index.html │ │ ├── objects.inv │ │ ├── py-modindex.html │ │ ├── pyray.html │ │ ├── raylib.html │ │ ├── rlzero.html │ │ ├── search.html │ │ └── searchindex.js ├── _config.yml ├── conf.py ├── examples ├── examples.rst ├── generated │ ├── rlzero.Actor.rst │ ├── rlzero.Cube.rst │ ├── rlzero.Gamepad.rst │ ├── rlzero.Keyboard.rst │ ├── rlzero.Mouse.rst │ ├── rlzero.Shape.rst │ ├── rlzero.Sound.rst │ ├── rlzero.Sphere.rst │ ├── rlzero.mouse.rst │ └── rlzero.run.rst ├── index.rst ├── make.bat ├── pyray.rst ├── raylib.rst ├── requirements.txt └── rlzero.rst ├── docs ├── .buildinfo ├── .nojekyll ├── README.html ├── _sources │ ├── README.md.txt │ ├── examples.rst.txt │ ├── generated │ │ ├── rlzero.Actor.rst.txt │ │ ├── rlzero.Cube.rst.txt │ │ ├── rlzero.Gamepad.rst.txt │ │ ├── rlzero.Keyboard.rst.txt │ │ ├── rlzero.Mouse.rst.txt │ │ ├── rlzero.Shape.rst.txt │ │ ├── rlzero.Sound.rst.txt │ │ ├── rlzero.Sphere.rst.txt │ │ ├── rlzero.mouse.rst.txt │ │ └── rlzero.run.rst.txt │ ├── index.rst.txt │ ├── pyray.rst.txt │ ├── raylib.rst.txt │ └── rlzero.rst.txt ├── _static │ ├── basic.css │ ├── css │ │ ├── badge_only.css │ │ ├── fonts │ │ │ ├── Roboto-Slab-Bold.woff │ │ │ ├── Roboto-Slab-Bold.woff2 │ │ │ ├── Roboto-Slab-Regular.woff │ │ │ ├── Roboto-Slab-Regular.woff2 │ │ │ ├── fontawesome-webfont.eot │ │ │ ├── fontawesome-webfont.svg │ │ │ ├── fontawesome-webfont.ttf │ │ │ ├── fontawesome-webfont.woff │ │ │ ├── fontawesome-webfont.woff2 │ │ │ ├── lato-bold-italic.woff │ │ │ ├── lato-bold-italic.woff2 │ │ │ ├── lato-bold.woff │ │ │ ├── lato-bold.woff2 │ │ │ ├── lato-normal-italic.woff │ │ │ ├── lato-normal-italic.woff2 │ │ │ ├── lato-normal.woff │ │ │ └── lato-normal.woff2 │ │ └── theme.css │ ├── doctools.js │ ├── documentation_options.js │ ├── file.png │ ├── jquery-3.5.1.js │ ├── jquery.js │ ├── js │ │ ├── badge_only.js │ │ ├── html5shiv-printshiv.min.js │ │ ├── html5shiv.min.js │ │ └── theme.js │ ├── language_data.js │ ├── minus.png │ ├── plus.png │ ├── pygments.css │ ├── searchtools.js │ ├── underscore-1.13.1.js │ └── underscore.js ├── examples.html ├── generated │ ├── rlzero.Actor.html │ ├── rlzero.Cube.html │ ├── rlzero.Gamepad.html │ ├── rlzero.Keyboard.html │ ├── rlzero.Mouse.html │ ├── rlzero.Shape.html │ ├── rlzero.Sound.html │ ├── rlzero.Sphere.html │ ├── rlzero.mouse.html │ └── rlzero.run.html ├── genindex.html ├── index.html ├── objects.inv ├── py-modindex.html ├── pyray.html ├── raylib.html ├── rlzero.html ├── search.html └── searchindex.js ├── examples ├── 10_lines_circles.py ├── 11_moving_boxes.py ├── 12_sprites.py ├── 12b_background.py ├── 13_keyboard_input.py ├── 14_joystick_input.py ├── 15_collisions.py ├── 15b_chase.py ├── 15c_powerup.py ├── 16_collisions2_sound_animation.py ├── 16_sound.py ├── 17_mouse_input.py ├── 18_mouse_movement.py ├── 20_loops.py ├── 21_arrays.py ├── 22_animation.py ├── 23_simple_physics.py ├── 24_pong.py ├── 25_colours.py ├── 26_classes.py ├── 26_fullscreen_mode.py ├── 27_classes2.py ├── 27_displaying_text.py ├── 28_timer.py ├── 29_timer2.py ├── animation.py ├── chase_game │ ├── chase.py │ ├── chase1.py │ ├── chase2.py │ ├── chaser3.py │ ├── chaser4.py │ ├── chaser5.py │ ├── chaser6.py │ ├── chaser7.py │ ├── coin.png │ └── images │ │ ├── alien.png │ │ ├── alien_hurt.png │ │ ├── background.png │ │ ├── badguy.png │ │ ├── cat1.png │ │ ├── cat2.png │ │ ├── cat3.png │ │ ├── cat4.png │ │ ├── door.png │ │ ├── empty0.png │ │ ├── goal.png │ │ ├── goal2.png │ │ ├── key.png │ │ ├── player.png │ │ ├── splat.png │ │ ├── wall.png │ │ └── wall1.png ├── custom_main_loop.py ├── data │ ├── images │ │ ├── alien.png │ │ ├── alien_hurt.png │ │ ├── background.png │ │ ├── badguy.png │ │ ├── cat1.png │ │ ├── cat2.png │ │ ├── cat3.png │ │ ├── cat4.png │ │ ├── door.png │ │ ├── empty0.png │ │ ├── goal.png │ │ ├── goal2.png │ │ ├── key.png │ │ ├── player.png │ │ ├── splat.png │ │ ├── wall.png │ │ └── wall1.png │ ├── models │ │ ├── __init__.py │ │ ├── characters │ │ │ ├── BlueSoldier_Female.glb │ │ │ ├── BlueSoldier_Female.glb.import │ │ │ ├── BlueSoldier_Male.glb │ │ │ ├── BlueSoldier_Male.glb.import │ │ │ ├── Casual2_Female.glb │ │ │ ├── Casual2_Female.glb.import │ │ │ ├── Casual2_Male.glb │ │ │ ├── Casual2_Male.glb.import │ │ │ ├── License.txt │ │ │ ├── Worker_Female.glb │ │ │ ├── Worker_Female.glb.import │ │ │ ├── Worker_Male.glb │ │ │ ├── Worker_Male.glb.import │ │ │ ├── Zombie_Female.glb │ │ │ ├── Zombie_Female.glb.import │ │ │ ├── Zombie_Male.glb │ │ │ └── Zombie_Male.glb.import │ │ ├── monsters │ │ │ ├── Bat.glb │ │ │ ├── Bat.glb.import │ │ │ ├── Belly.material │ │ │ ├── Black.material │ │ │ ├── Body.material │ │ │ ├── Claws.material │ │ │ ├── Dragon.glb │ │ │ ├── Dragon.glb.import │ │ │ ├── Eyes.material │ │ │ ├── License.txt │ │ │ ├── Main.material │ │ │ ├── Nose.material │ │ │ ├── Skeleton.glb │ │ │ ├── Skeleton.glb.import │ │ │ ├── Slime.glb │ │ │ ├── Slime.glb.import │ │ │ └── Wings.material │ │ └── rpg_characters │ │ │ ├── Cleric.glb │ │ │ ├── Cleric.glb.import │ │ │ ├── Monk.glb │ │ │ ├── Monk.glb.import │ │ │ ├── Ranger.glb │ │ │ ├── Ranger.glb.import │ │ │ ├── Rogue.glb │ │ │ ├── Rogue.glb.import │ │ │ ├── Warrior.glb │ │ │ ├── Warrior.glb.import │ │ │ ├── Wizard.glb │ │ │ └── Wizard.glb.import │ └── sounds │ │ └── eep.wav ├── mand.py ├── mand2.py ├── mand3.py ├── mand4.py ├── mand5.py ├── mand5b.py ├── mand5c.py ├── mand5d.py ├── mand5e.py ├── mand5f.py ├── mand6.py ├── mand7.py ├── mand8.py ├── pixels.py ├── race7_test.py ├── rl_actors.py ├── rl_collisions.py ├── rl_cubes_spheres.py ├── rl_demo.py ├── rl_displaying_text.py ├── rl_joystick_input.py ├── rl_keyboard_input.py ├── rl_mouse.py ├── rl_mouse_collisions.py ├── rl_moving_cubes.py ├── rl_sounds.py ├── rlzero ├── rotate.py └── shoot17_test.py ├── rlzero ├── Animation.py ├── Gamepad.py ├── Keyboard.py ├── Model.py ├── Mouse.py ├── Sound.py ├── Sprite.py ├── __init__.py ├── __main__.py ├── basic_lighting.fs ├── basic_lighting.vs ├── common.py ├── data │ ├── images │ │ ├── alien.png │ │ └── alien_hurt.png │ ├── models │ │ └── Wizard.glb │ └── sounds │ │ └── eep.wav ├── globals.py ├── rlights.py ├── rlzero.iml ├── runner.py ├── shape.py └── util.py ├── setup.py ├── test.mtl ├── test.obj ├── test.py └── test_rlzero.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | build/ 12 | develop-eggs/ 13 | dist/ 14 | downloads/ 15 | eggs/ 16 | .eggs/ 17 | lib/ 18 | lib64/ 19 | parts/ 20 | sdist/ 21 | var/ 22 | wheels/ 23 | *.egg-info/ 24 | .installed.cfg 25 | *.egg 26 | MANIFEST 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | .pytest_cache/ 49 | 50 | # Translations 51 | *.mo 52 | *.pot 53 | 54 | # Django stuff: 55 | *.log 56 | local_settings.py 57 | db.sqlite3 58 | 59 | # Flask stuff: 60 | instance/ 61 | .webassets-cache 62 | 63 | # Scrapy stuff: 64 | .scrapy 65 | 66 | # Sphinx documentation 67 | docs/_build/ 68 | 69 | # PyBuilder 70 | target/ 71 | 72 | # Jupyter Notebook 73 | .ipynb_checkpoints 74 | 75 | # pyenv 76 | .python-version 77 | 78 | # celery beat schedule file 79 | celerybeat-schedule 80 | 81 | # SageMath parsed files 82 | *.sage.py 83 | 84 | # Environments 85 | .env 86 | .venv 87 | env/ 88 | venv/ 89 | ENV/ 90 | env.bak/ 91 | venv.bak/ 92 | 93 | # Spyder project settings 94 | .spyderproject 95 | .spyproject 96 | 97 | # Rope project settings 98 | .ropeproject 99 | 100 | # mkdocs documentation 101 | /site 102 | 103 | # mypy 104 | .mypy_cache/ 105 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 14 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/rlzero.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include rlzero/* 2 | include rlzero/data/* 3 | include rlzero/data/models/* 4 | include rlzero/data/sounds/* 5 | include rlzero/data/images/* 6 | 7 | -------------------------------------------------------------------------------- /bin/rlzrun: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | python3 -m rlzero $1 3 | 4 | -------------------------------------------------------------------------------- /coords_demo.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | 4 | WIDTH=1200 5 | HEIGHT=800 6 | CAMERA=pr.CAMERA_FIRST_PERSON 7 | 8 | 9 | player = Box((-5, 0, -5), (1, 1, 1), 'green', True) 10 | 11 | 12 | o = Vector([-5,-0,-5]) 13 | 14 | td = False 15 | 16 | 17 | def init(): 18 | camera.position = (0.0, 4, 7) 19 | camera.target = (100,100,-100) 20 | camera.up = (0, 1, 0) 21 | camera.fovy = 60 22 | #rl.UpdateCamera(camera) 23 | pr.set_camera_mode(camera[0], pr.CAMERA_FIRST_PERSON) 24 | #rl.UpdateCamera(camera) 25 | 26 | def update(): 27 | if keyboard.right: 28 | player.pos.x += 0.1 29 | elif keyboard.left: 30 | player.pos.x -= 0.1 31 | elif keyboard.up: 32 | player.pos.y += 0.1 33 | elif keyboard.down: 34 | player.pos.y -= 0.1 35 | elif keyboard.l: 36 | player.pos.z += 0.1 37 | elif keyboard.p: 38 | player.pos.z-= 0.1 39 | 40 | if pr.is_key_pressed(pr.KEY_Z): 41 | global td 42 | td = not td 43 | 44 | 45 | def draw3d(): 46 | if td: 47 | #pyray.draw_plane((0, 0, 0), (300,300), DARKRED) 48 | pr.draw_grid(10, 1) 49 | pr.draw_plane((player.x, 0, player.z), (1, 1), GRAY) 50 | pr.draw_ray([o, [0, 0, 1]], BLUE) 51 | pr.draw_ray([o, [0, 1, 0]], GREEN) 52 | pr.draw_ray([o, [1, 0, 0]], RED) 53 | player.draw() 54 | 55 | 56 | def draw2dbackground(): 57 | clear('white') 58 | origin = rl.GetWorldToScreen(o, camera[0]) 59 | rl.DrawText(b"0", int(origin.x), int(origin.y), 20, BLACK) 60 | for i in range (0,11): 61 | xa = rl.GetWorldToScreen((o.x+i,o.y,o.z), camera[0]) 62 | ya = rl.GetWorldToScreen((o.x,o.y+i,o.z), camera[0]) 63 | za = rl.GetWorldToScreen((o.x,o.y,o.z+i), camera[0]) 64 | pr.draw_text(str(i), int(xa.x), int(xa.y), 20, RED) 65 | pr.draw_text(str(i), int(ya.x), int(ya.y), 20, GREEN) 66 | if td: 67 | pr.draw_text(str(i), int(za.x), int(za.y), 20, BLUE) 68 | 69 | pr.draw_text(f"X: {int(player.x + 5)}", 10, 10, 30, RED) 70 | pr.draw_text(f"Y: {int(player.y)}", 10, 50, 30, GREEN) 71 | if td: 72 | pr.draw_text(f"Z: {int(player.z + 5)}", 10, 110, 30, BLUE) 73 | 74 | 75 | 76 | run() 77 | -------------------------------------------------------------------------------- /docs-src/Makefile: -------------------------------------------------------------------------------- 1 | # Minimal makefile for Sphinx documentation 2 | # 3 | 4 | # You can set these variables from the command line, and also 5 | # from the environment for the first two. 6 | SPHINXOPTS ?= 7 | SPHINXBUILD ?= sphinx-build 8 | SOURCEDIR = . 9 | BUILDDIR = _build 10 | 11 | # Put it first so that "make" without argument is like "make help". 12 | help: 13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 14 | 15 | .PHONY: help Makefile 16 | 17 | # Catch-all target: route all unknown targets to Sphinx using the new 18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). 19 | %: Makefile 20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) 21 | -------------------------------------------------------------------------------- /docs-src/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /docs-src/_build/doctrees/README.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/README.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/environment.pickle: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/environment.pickle -------------------------------------------------------------------------------- /docs-src/_build/doctrees/examples.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/examples.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Actor.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Actor.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Cube.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Cube.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Gamepad.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Gamepad.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Keyboard.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Keyboard.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Mouse.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Mouse.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Shape.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Shape.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Sound.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Sound.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.Sphere.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.Sphere.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.mouse.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.mouse.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/generated/rlzero.run.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/generated/rlzero.run.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/index.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/index.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/pyray.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/pyray.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/raylib.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/raylib.doctree -------------------------------------------------------------------------------- /docs-src/_build/doctrees/rlzero.doctree: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/doctrees/rlzero.doctree -------------------------------------------------------------------------------- /docs-src/_build/html/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 10ee6a8d940af69f6ea329cfeddbd181 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/README.md.txt: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | A simplified API for Raylib for use in education and to enable beginners to create 3d games. 4 | 5 | Current state: 6 | 7 | ## Use 8 | 9 | ``` 10 | pip3 install rlzero 11 | ``` 12 | 13 | RLZero is just a few classes that sit on top of Raylib. Once you have imported RLZero you automatically get all of Raylib 14 | and you could copy any Raylib Python example code you find. Then if you want to use RLZero's classes as well as Raylib you can. 15 | 16 | The normal way of using RLZero is not to write your own main game loop. Instead, you set some 17 | variables to tell RLZero how you'd like 18 | your game to be define some specially named methods. 19 | 20 | **test.py**: 21 | ```python 22 | WIDTH=800 23 | HEIGHT=640 24 | CAMERA=rl.CAMERA_FIRST_PERSON 25 | DATA_DIR="examples/models/resources/models/" 26 | 27 | cube = Cube((0, 10, 0), (10, 20, 10), 'blue') 28 | 29 | def draw(): 30 | clear() 31 | cube.draw() 32 | 33 | def update(): 34 | cube.x = cube.x + 1 35 | if cube.x > 100: 36 | cube.x = -100 37 | ``` 38 | 39 | Then you tell RLZero to run your methods in its game loop: 40 | 41 | python -m rlzero test.py 42 | 43 | 44 | All the runner module does it add this line to the top of your code: 45 | 46 | ```python 47 | from rlzero import * 48 | ``` 49 | 50 | and this line to the bottom of your code: 51 | 52 | ```python 53 | run() 54 | ``` 55 | 56 | So if you can't use the runner, you can do that manually. 57 | 58 | ## Differences from Pygame Zero 59 | 60 | 1. We don't have a special mode in the Mu editor like Pygame Zero does, and therefore it is necessary to add an `import` line to the start of 61 | every program, and a `run()` line to the end. 62 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/examples.rst.txt: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | 5 | .. literalinclude:: examples/rl_actors.py 6 | :caption: Models 7 | 8 | .. literalinclude:: examples/rl_collisions.py 9 | :caption: Models 10 | 11 | .. literalinclude:: examples/rl_demo.py 12 | :caption: Models 13 | 14 | .. literalinclude:: examples/rl_displaying_text.py 15 | :caption: Models 16 | 17 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Actor.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Model 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Model 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Model.__init__ 17 | ~Model.calc_bounding_box 18 | ~Model.calc_centre 19 | ~Model.check_collision 20 | ~Model.draw 21 | ~Model.load_data 22 | ~Model.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Model.color 33 | ~Model.pos 34 | ~Model.size 35 | ~Model.wire_color 36 | ~Model.x 37 | ~Model.y 38 | ~Model.z 39 | 40 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Cube.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Cube 2 | =========== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Cube 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Cube.__init__ 17 | ~Cube.calc_bounding_box 18 | ~Cube.calc_centre 19 | ~Cube.check_collision 20 | ~Cube.draw 21 | ~Cube.load_data 22 | ~Cube.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Cube.color 33 | ~Cube.pos 34 | ~Cube.size 35 | ~Cube.wire_color 36 | ~Cube.x 37 | ~Cube.y 38 | ~Cube.z 39 | 40 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Gamepad.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Gamepad 2 | ============== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Gamepad 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Gamepad.__init__ 17 | ~Gamepad.test 18 | 19 | 20 | 21 | 22 | 23 | .. rubric:: Attributes 24 | 25 | .. autosummary:: 26 | 27 | ~Gamepad.a 28 | ~Gamepad.b 29 | ~Gamepad.down 30 | ~Gamepad.left 31 | ~Gamepad.left_stick 32 | ~Gamepad.right 33 | ~Gamepad.right_stick 34 | ~Gamepad.up 35 | ~Gamepad.x 36 | ~Gamepad.y 37 | 38 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Keyboard.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Keyboard 2 | =============== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Keyboard 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Keyboard.__init__ 17 | ~Keyboard.key_down 18 | ~Keyboard.key_pressed 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Mouse.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Mouse 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Mouse 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Mouse.__init__ 17 | ~Mouse.check_collision 18 | ~Mouse.get_position_on_ground 19 | 20 | 21 | 22 | 23 | 24 | .. rubric:: Attributes 25 | 26 | .. autosummary:: 27 | 28 | ~Mouse.clicked 29 | ~Mouse.ground_position 30 | ~Mouse.left_button 31 | ~Mouse.middle_button 32 | ~Mouse.right_button 33 | 34 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Shape.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Shape 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Shape 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Shape.__init__ 17 | 18 | 19 | 20 | 21 | 22 | .. rubric:: Attributes 23 | 24 | .. autosummary:: 25 | 26 | ~Shape.color 27 | ~Shape.pos 28 | ~Shape.wire_color 29 | ~Shape.x 30 | ~Shape.y 31 | ~Shape.z 32 | 33 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Sound.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Sound 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Sound 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Sound.__init__ 17 | ~Sound.load_data 18 | ~Sound.play 19 | 20 | 21 | 22 | 23 | 24 | .. rubric:: Attributes 25 | 26 | .. autosummary:: 27 | 28 | ~Sound.pitch 29 | ~Sound.volume 30 | 31 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.Sphere.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Sphere 2 | ============= 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Sphere 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Sphere.__init__ 17 | ~Sphere.calc_bounding_box 18 | ~Sphere.calc_centre 19 | ~Sphere.check_collision 20 | ~Sphere.draw 21 | ~Sphere.load_data 22 | ~Sphere.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Sphere.color 33 | ~Sphere.pos 34 | ~Sphere.size 35 | ~Sphere.wire_color 36 | ~Sphere.x 37 | ~Sphere.y 38 | ~Sphere.z 39 | 40 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.mouse.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.mouse 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autodata:: mouse -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/generated/rlzero.run.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.run 2 | ========== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autofunction:: run -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | .. RL Zero documentation master file, created by 2 | sphinx-quickstart on Mon Jul 12 14:03:57 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to RLZero 7 | =================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 3 11 | :caption: Contents: 12 | 13 | README 14 | rlzero 15 | examples 16 | 17 | .. toctree:: 18 | :maxdepth: 3 19 | :caption: Additional: 20 | 21 | raylib 22 | pyray 23 | examples/rl_collisions.py 24 | 25 | * :ref:`genindex` 26 | * :ref:`search` 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/pyray.rst.txt: -------------------------------------------------------------------------------- 1 | pyray 2 | ====== 3 | 4 | These are the same functions from :doc:`raylib ` but with some helpers and nicer naming. 5 | 6 | .. automodule:: raylib.pyray 7 | :members: 8 | :undoc-members: 9 | 10 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/raylib.rst.txt: -------------------------------------------------------------------------------- 1 | .. _raylib: 2 | 3 | raylib 4 | ====== 5 | 6 | The following functions from `Raylib `_ are available. 7 | 8 | .. automodule:: raylib.static.rl 9 | :members: 10 | :undoc-members: 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs-src/_build/html/_sources/rlzero.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero 2 | ====== 3 | 4 | 5 | .. currentmodule:: rlzero 6 | 7 | .. autosummary:: 8 | :toctree: generated 9 | :recursive: 10 | 11 | Model 12 | Cube 13 | Keyboard 14 | Mouse 15 | Gamepad 16 | Shape 17 | Sphere 18 | Sound 19 | 20 | 21 | run 22 | mouse 23 | 24 | 25 | 26 | .. automodule:: rlzero 27 | :members: 28 | :undoc-members: 29 | 30 | -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/badge_only.css: -------------------------------------------------------------------------------- 1 | .fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/Roboto-Slab-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/Roboto-Slab-Bold.woff -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/Roboto-Slab-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/Roboto-Slab-Bold.woff2 -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/Roboto-Slab-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/Roboto-Slab-Regular.woff -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/Roboto-Slab-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/Roboto-Slab-Regular.woff2 -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-bold-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-bold-italic.woff -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-bold-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-bold-italic.woff2 -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-bold.woff -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-bold.woff2 -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-normal-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-normal-italic.woff -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-normal-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-normal-italic.woff2 -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-normal.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-normal.woff -------------------------------------------------------------------------------- /docs-src/_build/html/_static/css/fonts/lato-normal.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/css/fonts/lato-normal.woff2 -------------------------------------------------------------------------------- /docs-src/_build/html/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: '', 4 | LANGUAGE: 'None', 5 | COLLAPSE_INDEX: false, 6 | BUILDER: 'html', 7 | FILE_SUFFIX: '.html', 8 | LINK_SUFFIX: '.html', 9 | HAS_SOURCE: true, 10 | SOURCELINK_SUFFIX: '.txt', 11 | NAVIGATION_WITH_KEYS: false 12 | }; -------------------------------------------------------------------------------- /docs-src/_build/html/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs-src/_build/html/_static/file.png -------------------------------------------------------------------------------- /docs-src/_build/html/_static/js/badge_only.js: -------------------------------------------------------------------------------- 1 | !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}}); -------------------------------------------------------------------------------- /docs-src/_build/html/_static/js/html5shiv-printshiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs-src/_build/html/_static/js/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs-src/_build/html/_static/js/theme.js: -------------------------------------------------------------------------------- 1 | !function(n){var e={};function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:i})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(i,o,function(e){return n[e]}.bind(null,o));return i},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){t(1),n.exports=t(3)},function(n,e,t){(function(){var e="undefined"!=typeof window?window.jQuery:t(2);n.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(n){var t=this;void 0===n&&(n=!0),t.isRunning||(t.isRunning=!0,e((function(e){t.init(e),t.reset(),t.win.on("hashchange",t.reset),n&&t.win.on("scroll",(function(){t.linkScroll||t.winScroll||(t.winScroll=!0,requestAnimationFrame((function(){t.onScroll()})))})),t.win.on("resize",(function(){t.winResize||(t.winResize=!0,requestAnimationFrame((function(){t.onResize()})))})),t.onResize()})))},enableSticky:function(){this.enable(!0)},init:function(n){n(document);var e=this;this.navBar=n("div.wy-side-scroll:first"),this.win=n(window),n(document).on("click","[data-toggle='wy-nav-top']",(function(){n("[data-toggle='wy-nav-shift']").toggleClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift")})).on("click",".wy-menu-vertical .current ul li a",(function(){var t=n(this);n("[data-toggle='wy-nav-shift']").removeClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift"),e.toggleCurrent(t),e.hashChange()})).on("click","[data-toggle='rst-current-version']",(function(){n("[data-toggle='rst-versions']").toggleClass("shift-up")})),n("table.docutils:not(.field-list,.footnote,.citation)").wrap("
"),n("table.docutils.footnote").wrap("
"),n("table.docutils.citation").wrap("
"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n(''),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}if(t.length>0){$(".wy-menu-vertical .current").removeClass("current").attr("aria-expanded","false"),t.addClass("current").attr("aria-expanded","true"),t.closest("li.toctree-l1").parent().addClass("current").attr("aria-expanded","true");for(let n=1;n<=10;n++)t.closest("li.toctree-l"+n).addClass("current").attr("aria-expanded","true");t[0].scrollIntoView()}}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current").attr("aria-expanded","false"),e.siblings().find("li.current").removeClass("current").attr("aria-expanded","false");var t=e.find("> ul li");t.length&&(t.removeClass("current").attr("aria-expanded","false"),e.toggleClass("current").attr("aria-expanded",(function(n,e){return"true"==e?"false":"true"})))}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t 2 | 3 | 4 | 5 | 6 | Search — RLZero documentation 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 55 | 56 |
60 | 61 |
62 |
63 |
64 |
    65 |
  • »
  • 66 |
  • Search
  • 67 |
  • 68 |
  • 69 |
70 |
71 |
72 |
73 |
74 | 75 | 82 | 83 | 84 |
85 | 86 |
87 | 88 |
89 |
90 |
91 | 92 |
93 | 94 |
95 |

© Copyright 2021, Richard Smith.

96 |
97 | 98 | Built with Sphinx using a 99 | theme 100 | provided by Read the Docs. 101 | 102 | 103 |
104 |
105 |
106 |
107 |
108 | 113 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /docs-src/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /docs-src/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # This file only contains a selection of the most common options. For a full 4 | # list see the documentation: 5 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 6 | 7 | # -- Path setup -------------------------------------------------------------- 8 | 9 | # If extensions (or modules to document with autodoc) are in another directory, 10 | # add these directories to sys.path here. If the directory is relative to the 11 | # documentation root, use os.path.abspath to make it absolute, like shown here. 12 | # 13 | import os 14 | import sys 15 | import sphinx_rtd_theme 16 | sys.path.insert(0, os.path.abspath('../')) 17 | 18 | 19 | # -- Project information ----------------------------------------------------- 20 | 21 | project = 'RLZero' 22 | copyright = '2021, Richard Smith' 23 | author = 'Richard Smith' 24 | 25 | 26 | # -- General configuration --------------------------------------------------- 27 | 28 | # Add any Sphinx extension module names here, as strings. They can be 29 | # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom 30 | # ones. 31 | extensions = ['sphinx.ext.autodoc', 'sphinx.ext.autosummary', 'myst_parser', "sphinx_rtd_theme"] 32 | 33 | autosummary_generate = True 34 | 35 | # Add any paths that contain templates here, relative to this directory. 36 | templates_path = ['_templates'] 37 | 38 | # List of patterns, relative to source directory, that match files and 39 | # directories to ignore when looking for source files. 40 | # This pattern also affects html_static_path and html_extra_path. 41 | exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] 42 | 43 | 44 | # -- Options for HTML output ------------------------------------------------- 45 | 46 | # The theme to use for HTML and HTML Help pages. See the documentation for 47 | # a list of builtin themes. 48 | # 49 | html_theme = "sphinx_rtd_theme" 50 | 51 | # Add any paths that contain custom static files (such as style sheets) here, 52 | # relative to this directory. They are copied after the builtin static files, 53 | # so a file named "default.css" will overwrite the builtin "default.css". 54 | html_static_path = ['_static'] 55 | 56 | pygments_style = 'sphinx' 57 | -------------------------------------------------------------------------------- /docs-src/examples: -------------------------------------------------------------------------------- 1 | ../examples/ -------------------------------------------------------------------------------- /docs-src/examples.rst: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | 5 | .. literalinclude:: examples/rl_actors.py 6 | :caption: Models 7 | 8 | .. literalinclude:: examples/rl_collisions.py 9 | :caption: Models 10 | 11 | .. literalinclude:: examples/rl_demo.py 12 | :caption: Models 13 | 14 | .. literalinclude:: examples/rl_displaying_text.py 15 | :caption: Models 16 | 17 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Actor.rst: -------------------------------------------------------------------------------- 1 | rlzero.Model 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Model 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Model.__init__ 17 | ~Model.calc_bounding_box 18 | ~Model.calc_centre 19 | ~Model.check_collision 20 | ~Model.draw 21 | ~Model.load_data 22 | ~Model.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Model.color 33 | ~Model.pos 34 | ~Model.size 35 | ~Model.wire_color 36 | ~Model.x 37 | ~Model.y 38 | ~Model.z 39 | 40 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Cube.rst: -------------------------------------------------------------------------------- 1 | rlzero.Cube 2 | =========== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Cube 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Cube.__init__ 17 | ~Cube.calc_bounding_box 18 | ~Cube.calc_centre 19 | ~Cube.check_collision 20 | ~Cube.draw 21 | ~Cube.load_data 22 | ~Cube.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Cube.color 33 | ~Cube.pos 34 | ~Cube.size 35 | ~Cube.wire_color 36 | ~Cube.x 37 | ~Cube.y 38 | ~Cube.z 39 | 40 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Gamepad.rst: -------------------------------------------------------------------------------- 1 | rlzero.Gamepad 2 | ============== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Gamepad 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Gamepad.__init__ 17 | ~Gamepad.test 18 | 19 | 20 | 21 | 22 | 23 | .. rubric:: Attributes 24 | 25 | .. autosummary:: 26 | 27 | ~Gamepad.a 28 | ~Gamepad.b 29 | ~Gamepad.down 30 | ~Gamepad.left 31 | ~Gamepad.left_stick 32 | ~Gamepad.right 33 | ~Gamepad.right_stick 34 | ~Gamepad.up 35 | ~Gamepad.x 36 | ~Gamepad.y 37 | 38 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Keyboard.rst: -------------------------------------------------------------------------------- 1 | rlzero.Keyboard 2 | =============== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Keyboard 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Keyboard.__init__ 17 | ~Keyboard.key_down 18 | ~Keyboard.key_pressed 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Mouse.rst: -------------------------------------------------------------------------------- 1 | rlzero.Mouse 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Mouse 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Mouse.__init__ 17 | ~Mouse.check_collision 18 | ~Mouse.get_position_on_ground 19 | 20 | 21 | 22 | 23 | 24 | .. rubric:: Attributes 25 | 26 | .. autosummary:: 27 | 28 | ~Mouse.clicked 29 | ~Mouse.ground_position 30 | ~Mouse.left_button 31 | ~Mouse.middle_button 32 | ~Mouse.right_button 33 | 34 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Shape.rst: -------------------------------------------------------------------------------- 1 | rlzero.Shape 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Shape 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Shape.__init__ 17 | 18 | 19 | 20 | 21 | 22 | .. rubric:: Attributes 23 | 24 | .. autosummary:: 25 | 26 | ~Shape.color 27 | ~Shape.pos 28 | ~Shape.wire_color 29 | ~Shape.x 30 | ~Shape.y 31 | ~Shape.z 32 | 33 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Sound.rst: -------------------------------------------------------------------------------- 1 | rlzero.Sound 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Sound 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Sound.__init__ 17 | ~Sound.load_data 18 | ~Sound.play 19 | 20 | 21 | 22 | 23 | 24 | .. rubric:: Attributes 25 | 26 | .. autosummary:: 27 | 28 | ~Sound.pitch 29 | ~Sound.volume 30 | 31 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.Sphere.rst: -------------------------------------------------------------------------------- 1 | rlzero.Sphere 2 | ============= 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Sphere 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Sphere.__init__ 17 | ~Sphere.calc_bounding_box 18 | ~Sphere.calc_centre 19 | ~Sphere.check_collision 20 | ~Sphere.draw 21 | ~Sphere.load_data 22 | ~Sphere.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Sphere.color 33 | ~Sphere.pos 34 | ~Sphere.size 35 | ~Sphere.wire_color 36 | ~Sphere.x 37 | ~Sphere.y 38 | ~Sphere.z 39 | 40 | -------------------------------------------------------------------------------- /docs-src/generated/rlzero.mouse.rst: -------------------------------------------------------------------------------- 1 | rlzero.mouse 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autodata:: mouse -------------------------------------------------------------------------------- /docs-src/generated/rlzero.run.rst: -------------------------------------------------------------------------------- 1 | rlzero.run 2 | ========== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autofunction:: run -------------------------------------------------------------------------------- /docs-src/index.rst: -------------------------------------------------------------------------------- 1 | .. RL Zero documentation master file, created by 2 | sphinx-quickstart on Mon Jul 12 14:03:57 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to RLZero 7 | =================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 3 11 | :caption: Contents: 12 | 13 | README 14 | rlzero 15 | examples 16 | 17 | .. toctree:: 18 | :maxdepth: 3 19 | :caption: Additional: 20 | 21 | raylib 22 | pyray 23 | examples/rl_collisions.py 24 | 25 | * :ref:`genindex` 26 | * :ref:`search` 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /docs-src/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | pushd %~dp0 4 | 5 | REM Command file for Sphinx documentation 6 | 7 | if "%SPHINXBUILD%" == "" ( 8 | set SPHINXBUILD=sphinx-build 9 | ) 10 | set SOURCEDIR=. 11 | set BUILDDIR=_build 12 | 13 | if "%1" == "" goto help 14 | 15 | %SPHINXBUILD% >NUL 2>NUL 16 | if errorlevel 9009 ( 17 | echo. 18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 19 | echo.installed, then set the SPHINXBUILD environment variable to point 20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 21 | echo.may add the Sphinx directory to PATH. 22 | echo. 23 | echo.If you don't have Sphinx installed, grab it from 24 | echo.http://sphinx-doc.org/ 25 | exit /b 1 26 | ) 27 | 28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 29 | goto end 30 | 31 | :help 32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% 33 | 34 | :end 35 | popd 36 | -------------------------------------------------------------------------------- /docs-src/pyray.rst: -------------------------------------------------------------------------------- 1 | pyray 2 | ====== 3 | 4 | These are the same functions from :doc:`raylib ` but with some helpers and nicer naming. 5 | 6 | .. automodule:: raylib.pyray 7 | :members: 8 | :undoc-members: 9 | 10 | -------------------------------------------------------------------------------- /docs-src/raylib.rst: -------------------------------------------------------------------------------- 1 | .. _raylib: 2 | 3 | raylib 4 | ====== 5 | 6 | The following functions from `Raylib `_ are available. 7 | 8 | .. automodule:: raylib.static.rl 9 | :members: 10 | :undoc-members: 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs-src/requirements.txt: -------------------------------------------------------------------------------- 1 | myst_parser 2 | -------------------------------------------------------------------------------- /docs-src/rlzero.rst: -------------------------------------------------------------------------------- 1 | rlzero 2 | ====== 3 | 4 | 5 | .. currentmodule:: rlzero 6 | 7 | .. autosummary:: 8 | :toctree: generated 9 | :recursive: 10 | 11 | Model 12 | Cube 13 | Keyboard 14 | Mouse 15 | Gamepad 16 | Shape 17 | Sphere 18 | Sound 19 | 20 | 21 | run 22 | mouse 23 | 24 | 25 | 26 | .. automodule:: rlzero 27 | :members: 28 | :undoc-members: 29 | 30 | -------------------------------------------------------------------------------- /docs/.buildinfo: -------------------------------------------------------------------------------- 1 | # Sphinx build info version 1 2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. 3 | config: 10ee6a8d940af69f6ea329cfeddbd181 4 | tags: 645f666f9bcd5a90fca523b33c5a78b7 5 | -------------------------------------------------------------------------------- /docs/.nojekyll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/.nojekyll -------------------------------------------------------------------------------- /docs/_sources/README.md.txt: -------------------------------------------------------------------------------- 1 | # README 2 | 3 | A simplified API for Raylib for use in education and to enable beginners to create 3d games. 4 | 5 | Current state: 6 | 7 | ## Use 8 | 9 | ``` 10 | pip3 install rlzero 11 | ``` 12 | 13 | RLZero is just a few classes that sit on top of Raylib. Once you have imported RLZero you automatically get all of Raylib 14 | and you could copy any Raylib Python example code you find. Then if you want to use RLZero's classes as well as Raylib you can. 15 | 16 | The normal way of using RLZero is not to write your own main game loop. Instead, you set some 17 | variables to tell RLZero how you'd like 18 | your game to be define some specially named methods. 19 | 20 | **test.py**: 21 | ```python 22 | WIDTH=800 23 | HEIGHT=640 24 | CAMERA=rl.CAMERA_FIRST_PERSON 25 | DATA_DIR="examples/models/resources/models/" 26 | 27 | cube = Cube((0, 10, 0), (10, 20, 10), 'blue') 28 | 29 | def draw(): 30 | clear() 31 | cube.draw() 32 | 33 | def update(): 34 | cube.x = cube.x + 1 35 | if cube.x > 100: 36 | cube.x = -100 37 | ``` 38 | 39 | Then you tell RLZero to run your methods in its game loop: 40 | 41 | python -m rlzero test.py 42 | 43 | 44 | All the runner module does it add this line to the top of your code: 45 | 46 | ```python 47 | from rlzero import * 48 | ``` 49 | 50 | and this line to the bottom of your code: 51 | 52 | ```python 53 | run() 54 | ``` 55 | 56 | So if you can't use the runner, you can do that manually. 57 | 58 | ## Differences from Pygame Zero 59 | 60 | 1. We don't have a special mode in the Mu editor like Pygame Zero does, and therefore it is necessary to add an `import` line to the start of 61 | every program, and a `run()` line to the end. 62 | -------------------------------------------------------------------------------- /docs/_sources/examples.rst.txt: -------------------------------------------------------------------------------- 1 | Examples 2 | ======== 3 | 4 | 5 | .. literalinclude:: examples/rl_actors.py 6 | :caption: Models 7 | 8 | .. literalinclude:: examples/rl_collisions.py 9 | :caption: Models 10 | 11 | .. literalinclude:: examples/rl_demo.py 12 | :caption: Models 13 | 14 | .. literalinclude:: examples/rl_displaying_text.py 15 | :caption: Models 16 | 17 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Actor.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Model 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Model 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Model.__init__ 17 | ~Model.calc_bounding_box 18 | ~Model.calc_centre 19 | ~Model.check_collision 20 | ~Model.draw 21 | ~Model.load_data 22 | ~Model.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Model.color 33 | ~Model.pos 34 | ~Model.size 35 | ~Model.wire_color 36 | ~Model.x 37 | ~Model.y 38 | ~Model.z 39 | 40 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Cube.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Cube 2 | =========== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Cube 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Cube.__init__ 17 | ~Cube.calc_bounding_box 18 | ~Cube.calc_centre 19 | ~Cube.check_collision 20 | ~Cube.draw 21 | ~Cube.load_data 22 | ~Cube.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Cube.color 33 | ~Cube.pos 34 | ~Cube.size 35 | ~Cube.wire_color 36 | ~Cube.x 37 | ~Cube.y 38 | ~Cube.z 39 | 40 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Gamepad.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Gamepad 2 | ============== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Gamepad 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Gamepad.__init__ 17 | ~Gamepad.test 18 | 19 | 20 | 21 | 22 | 23 | .. rubric:: Attributes 24 | 25 | .. autosummary:: 26 | 27 | ~Gamepad.a 28 | ~Gamepad.b 29 | ~Gamepad.down 30 | ~Gamepad.left 31 | ~Gamepad.left_stick 32 | ~Gamepad.right 33 | ~Gamepad.right_stick 34 | ~Gamepad.up 35 | ~Gamepad.x 36 | ~Gamepad.y 37 | 38 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Keyboard.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Keyboard 2 | =============== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Keyboard 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Keyboard.__init__ 17 | ~Keyboard.key_down 18 | ~Keyboard.key_pressed 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Mouse.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Mouse 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Mouse 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Mouse.__init__ 17 | ~Mouse.check_collision 18 | ~Mouse.get_position_on_ground 19 | 20 | 21 | 22 | 23 | 24 | .. rubric:: Attributes 25 | 26 | .. autosummary:: 27 | 28 | ~Mouse.clicked 29 | ~Mouse.ground_position 30 | ~Mouse.left_button 31 | ~Mouse.middle_button 32 | ~Mouse.right_button 33 | 34 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Shape.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Shape 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Shape 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Shape.__init__ 17 | 18 | 19 | 20 | 21 | 22 | .. rubric:: Attributes 23 | 24 | .. autosummary:: 25 | 26 | ~Shape.color 27 | ~Shape.pos 28 | ~Shape.wire_color 29 | ~Shape.x 30 | ~Shape.y 31 | ~Shape.z 32 | 33 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Sound.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Sound 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Sound 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Sound.__init__ 17 | ~Sound.load_data 18 | ~Sound.play 19 | 20 | 21 | 22 | 23 | 24 | .. rubric:: Attributes 25 | 26 | .. autosummary:: 27 | 28 | ~Sound.pitch 29 | ~Sound.volume 30 | 31 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.Sphere.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.Sphere 2 | ============= 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autoclass:: Sphere 7 | 8 | 9 | .. automethod:: __init__ 10 | 11 | 12 | .. rubric:: Methods 13 | 14 | .. autosummary:: 15 | 16 | ~Sphere.__init__ 17 | ~Sphere.calc_bounding_box 18 | ~Sphere.calc_centre 19 | ~Sphere.check_collision 20 | ~Sphere.draw 21 | ~Sphere.load_data 22 | ~Sphere.load_data_obj 23 | 24 | 25 | 26 | 27 | 28 | .. rubric:: Attributes 29 | 30 | .. autosummary:: 31 | 32 | ~Sphere.color 33 | ~Sphere.pos 34 | ~Sphere.size 35 | ~Sphere.wire_color 36 | ~Sphere.x 37 | ~Sphere.y 38 | ~Sphere.z 39 | 40 | -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.mouse.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.mouse 2 | ============ 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autodata:: mouse -------------------------------------------------------------------------------- /docs/_sources/generated/rlzero.run.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero.run 2 | ========== 3 | 4 | .. currentmodule:: rlzero 5 | 6 | .. autofunction:: run -------------------------------------------------------------------------------- /docs/_sources/index.rst.txt: -------------------------------------------------------------------------------- 1 | .. RL Zero documentation master file, created by 2 | sphinx-quickstart on Mon Jul 12 14:03:57 2021. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | Welcome to RLZero 7 | =================================== 8 | 9 | .. toctree:: 10 | :maxdepth: 3 11 | :caption: Contents: 12 | 13 | README 14 | rlzero 15 | examples 16 | 17 | .. toctree:: 18 | :maxdepth: 3 19 | :caption: Additional: 20 | 21 | raylib 22 | pyray 23 | examples/rl_collisions.py 24 | 25 | * :ref:`genindex` 26 | * :ref:`search` 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /docs/_sources/pyray.rst.txt: -------------------------------------------------------------------------------- 1 | pyray 2 | ====== 3 | 4 | These are the same functions from :doc:`raylib ` but with some helpers and nicer naming. 5 | 6 | .. automodule:: raylib.pyray 7 | :members: 8 | :undoc-members: 9 | 10 | -------------------------------------------------------------------------------- /docs/_sources/raylib.rst.txt: -------------------------------------------------------------------------------- 1 | .. _raylib: 2 | 3 | raylib 4 | ====== 5 | 6 | The following functions from `Raylib `_ are available. 7 | 8 | .. automodule:: raylib.static.rl 9 | :members: 10 | :undoc-members: 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /docs/_sources/rlzero.rst.txt: -------------------------------------------------------------------------------- 1 | rlzero 2 | ====== 3 | 4 | 5 | .. currentmodule:: rlzero 6 | 7 | .. autosummary:: 8 | :toctree: generated 9 | :recursive: 10 | 11 | Model 12 | Cube 13 | Keyboard 14 | Mouse 15 | Gamepad 16 | Shape 17 | Sphere 18 | Sound 19 | 20 | 21 | run 22 | mouse 23 | 24 | 25 | 26 | .. automodule:: rlzero 27 | :members: 28 | :undoc-members: 29 | 30 | -------------------------------------------------------------------------------- /docs/_static/css/badge_only.css: -------------------------------------------------------------------------------- 1 | .fa:before{-webkit-font-smoothing:antialiased}.clearfix{*zoom:1}.clearfix:after,.clearfix:before{display:table;content:""}.clearfix:after{clear:both}@font-face{font-family:FontAwesome;font-style:normal;font-weight:400;src:url(fonts/fontawesome-webfont.eot?674f50d287a8c48dc19ba404d20fe713?#iefix) format("embedded-opentype"),url(fonts/fontawesome-webfont.woff2?af7ae505a9eed503f8b8e6982036873e) format("woff2"),url(fonts/fontawesome-webfont.woff?fee66e712a8a08eef5805a46892932ad) format("woff"),url(fonts/fontawesome-webfont.ttf?b06871f281fee6b241d60582ae9369b9) format("truetype"),url(fonts/fontawesome-webfont.svg?912ec66d7572ff821749319396470bde#FontAwesome) format("svg")}.fa:before{font-family:FontAwesome;font-style:normal;font-weight:400;line-height:1}.fa:before,a .fa{text-decoration:inherit}.fa:before,a .fa,li .fa{display:inline-block}li .fa-large:before{width:1.875em}ul.fas{list-style-type:none;margin-left:2em;text-indent:-.8em}ul.fas li .fa{width:.8em}ul.fas li .fa-large:before{vertical-align:baseline}.fa-book:before,.icon-book:before{content:"\f02d"}.fa-caret-down:before,.icon-caret-down:before{content:"\f0d7"}.fa-caret-up:before,.icon-caret-up:before{content:"\f0d8"}.fa-caret-left:before,.icon-caret-left:before{content:"\f0d9"}.fa-caret-right:before,.icon-caret-right:before{content:"\f0da"}.rst-versions{position:fixed;bottom:0;left:0;width:300px;color:#fcfcfc;background:#1f1d1d;font-family:Lato,proxima-nova,Helvetica Neue,Arial,sans-serif;z-index:400}.rst-versions a{color:#2980b9;text-decoration:none}.rst-versions .rst-badge-small{display:none}.rst-versions .rst-current-version{padding:12px;background-color:#272525;display:block;text-align:right;font-size:90%;cursor:pointer;color:#27ae60}.rst-versions .rst-current-version:after{clear:both;content:"";display:block}.rst-versions .rst-current-version .fa{color:#fcfcfc}.rst-versions .rst-current-version .fa-book,.rst-versions .rst-current-version .icon-book{float:left}.rst-versions .rst-current-version.rst-out-of-date{background-color:#e74c3c;color:#fff}.rst-versions .rst-current-version.rst-active-old-version{background-color:#f1c40f;color:#000}.rst-versions.shift-up{height:auto;max-height:100%;overflow-y:scroll}.rst-versions.shift-up .rst-other-versions{display:block}.rst-versions .rst-other-versions{font-size:90%;padding:12px;color:grey;display:none}.rst-versions .rst-other-versions hr{display:block;height:1px;border:0;margin:20px 0;padding:0;border-top:1px solid #413d3d}.rst-versions .rst-other-versions dd{display:inline-block;margin:0}.rst-versions .rst-other-versions dd a{display:inline-block;padding:6px;color:#fcfcfc}.rst-versions.rst-badge{width:auto;bottom:20px;right:20px;left:auto;border:none;max-width:300px;max-height:90%}.rst-versions.rst-badge .fa-book,.rst-versions.rst-badge .icon-book{float:none;line-height:30px}.rst-versions.rst-badge.shift-up .rst-current-version{text-align:right}.rst-versions.rst-badge.shift-up .rst-current-version .fa-book,.rst-versions.rst-badge.shift-up .rst-current-version .icon-book{float:left}.rst-versions.rst-badge>.rst-current-version{width:auto;height:30px;line-height:30px;padding:0 6px;display:block;text-align:center}@media screen and (max-width:768px){.rst-versions{width:85%;display:none}.rst-versions.shift{display:block}} -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/Roboto-Slab-Bold.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/Roboto-Slab-Bold.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/Roboto-Slab-Regular.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/Roboto-Slab-Regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/Roboto-Slab-Regular.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-bold-italic.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-bold-italic.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-bold.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-bold.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-bold.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal-italic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-normal-italic.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal-italic.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-normal-italic.woff2 -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-normal.woff -------------------------------------------------------------------------------- /docs/_static/css/fonts/lato-normal.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/css/fonts/lato-normal.woff2 -------------------------------------------------------------------------------- /docs/_static/documentation_options.js: -------------------------------------------------------------------------------- 1 | var DOCUMENTATION_OPTIONS = { 2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'), 3 | VERSION: '', 4 | LANGUAGE: 'None', 5 | COLLAPSE_INDEX: false, 6 | BUILDER: 'html', 7 | FILE_SUFFIX: '.html', 8 | LINK_SUFFIX: '.html', 9 | HAS_SOURCE: true, 10 | SOURCELINK_SUFFIX: '.txt', 11 | NAVIGATION_WITH_KEYS: false 12 | }; -------------------------------------------------------------------------------- /docs/_static/file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/docs/_static/file.png -------------------------------------------------------------------------------- /docs/_static/js/badge_only.js: -------------------------------------------------------------------------------- 1 | !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}}); -------------------------------------------------------------------------------- /docs/_static/js/html5shiv-printshiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3-pre | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=y.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=y.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),y.elements=c+" "+a,j(b)}function f(a){var b=x[a[v]];return b||(b={},w++,a[v]=w,x[w]=b),b}function g(a,c,d){if(c||(c=b),q)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():u.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||t.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),q)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return y.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(y,b.frag)}function j(a){a||(a=b);var d=f(a);return!y.shivCSS||p||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),q||i(a,d),a}function k(a){for(var b,c=a.getElementsByTagName("*"),e=c.length,f=RegExp("^(?:"+d().join("|")+")$","i"),g=[];e--;)b=c[e],f.test(b.nodeName)&&g.push(b.applyElement(l(b)));return g}function l(a){for(var b,c=a.attributes,d=c.length,e=a.ownerDocument.createElement(A+":"+a.nodeName);d--;)b=c[d],b.specified&&e.setAttribute(b.nodeName,b.nodeValue);return e.style.cssText=a.style.cssText,e}function m(a){for(var b,c=a.split("{"),e=c.length,f=RegExp("(^|[\\s,>+~])("+d().join("|")+")(?=[[\\s,>+~#.:]|$)","gi"),g="$1"+A+"\\:$2";e--;)b=c[e]=c[e].split("}"),b[b.length-1]=b[b.length-1].replace(f,g),c[e]=b.join("}");return c.join("{")}function n(a){for(var b=a.length;b--;)a[b].removeNode()}function o(a){function b(){clearTimeout(g._removeSheetTimer),d&&d.removeNode(!0),d=null}var d,e,g=f(a),h=a.namespaces,i=a.parentWindow;return!B||a.printShived?a:("undefined"==typeof h[A]&&h.add(A),i.attachEvent("onbeforeprint",function(){b();for(var f,g,h,i=a.styleSheets,j=[],l=i.length,n=Array(l);l--;)n[l]=i[l];for(;h=n.pop();)if(!h.disabled&&z.test(h.media)){try{f=h.imports,g=f.length}catch(o){g=0}for(l=0;g>l;l++)n.push(f[l]);try{j.push(h.cssText)}catch(o){}}j=m(j.reverse().join("")),e=k(a),d=c(a,j)}),i.attachEvent("onafterprint",function(){n(e),clearTimeout(g._removeSheetTimer),g._removeSheetTimer=setTimeout(b,500)}),a.printShived=!0,a)}var p,q,r="3.7.3",s=a.html5||{},t=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,u=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,v="_html5shiv",w=0,x={};!function(){try{var a=b.createElement("a");a.innerHTML="",p="hidden"in a,q=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){p=!0,q=!0}}();var y={elements:s.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:r,shivCSS:s.shivCSS!==!1,supportsUnknownElements:q,shivMethods:s.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=y,j(b);var z=/^$|\b(?:all|print)\b/,A="html5shiv",B=!q&&function(){var c=b.documentElement;return!("undefined"==typeof b.namespaces||"undefined"==typeof b.parentWindow||"undefined"==typeof c.applyElement||"undefined"==typeof c.removeNode||"undefined"==typeof a.attachEvent)}();y.type+=" print",y.shivPrint=o,o(b),"object"==typeof module&&module.exports&&(module.exports=y)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs/_static/js/html5shiv.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @preserve HTML5 Shiv 3.7.3 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed 3 | */ 4 | !function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.3-pre",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b),"object"==typeof module&&module.exports&&(module.exports=t)}("undefined"!=typeof window?window:this,document); -------------------------------------------------------------------------------- /docs/_static/js/theme.js: -------------------------------------------------------------------------------- 1 | !function(n){var e={};function t(i){if(e[i])return e[i].exports;var o=e[i]={i:i,l:!1,exports:{}};return n[i].call(o.exports,o,o.exports,t),o.l=!0,o.exports}t.m=n,t.c=e,t.d=function(n,e,i){t.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:i})},t.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},t.t=function(n,e){if(1&e&&(n=t(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var i=Object.create(null);if(t.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var o in n)t.d(i,o,function(e){return n[e]}.bind(null,o));return i},t.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,"a",e),e},t.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},t.p="",t(t.s=0)}([function(n,e,t){t(1),n.exports=t(3)},function(n,e,t){(function(){var e="undefined"!=typeof window?window.jQuery:t(2);n.exports.ThemeNav={navBar:null,win:null,winScroll:!1,winResize:!1,linkScroll:!1,winPosition:0,winHeight:null,docHeight:null,isRunning:!1,enable:function(n){var t=this;void 0===n&&(n=!0),t.isRunning||(t.isRunning=!0,e((function(e){t.init(e),t.reset(),t.win.on("hashchange",t.reset),n&&t.win.on("scroll",(function(){t.linkScroll||t.winScroll||(t.winScroll=!0,requestAnimationFrame((function(){t.onScroll()})))})),t.win.on("resize",(function(){t.winResize||(t.winResize=!0,requestAnimationFrame((function(){t.onResize()})))})),t.onResize()})))},enableSticky:function(){this.enable(!0)},init:function(n){n(document);var e=this;this.navBar=n("div.wy-side-scroll:first"),this.win=n(window),n(document).on("click","[data-toggle='wy-nav-top']",(function(){n("[data-toggle='wy-nav-shift']").toggleClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift")})).on("click",".wy-menu-vertical .current ul li a",(function(){var t=n(this);n("[data-toggle='wy-nav-shift']").removeClass("shift"),n("[data-toggle='rst-versions']").toggleClass("shift"),e.toggleCurrent(t),e.hashChange()})).on("click","[data-toggle='rst-current-version']",(function(){n("[data-toggle='rst-versions']").toggleClass("shift-up")})),n("table.docutils:not(.field-list,.footnote,.citation)").wrap("
"),n("table.docutils.footnote").wrap("
"),n("table.docutils.citation").wrap("
"),n(".wy-menu-vertical ul").not(".simple").siblings("a").each((function(){var t=n(this);expand=n(''),expand.on("click",(function(n){return e.toggleCurrent(t),n.stopPropagation(),!1})),t.prepend(expand)}))},reset:function(){var n=encodeURI(window.location.hash)||"#";try{var e=$(".wy-menu-vertical"),t=e.find('[href="'+n+'"]');if(0===t.length){var i=$('.document [id="'+n.substring(1)+'"]').closest("div.section");0===(t=e.find('[href="#'+i.attr("id")+'"]')).length&&(t=e.find('[href="#"]'))}if(t.length>0){$(".wy-menu-vertical .current").removeClass("current").attr("aria-expanded","false"),t.addClass("current").attr("aria-expanded","true"),t.closest("li.toctree-l1").parent().addClass("current").attr("aria-expanded","true");for(let n=1;n<=10;n++)t.closest("li.toctree-l"+n).addClass("current").attr("aria-expanded","true");t[0].scrollIntoView()}}catch(n){console.log("Error expanding nav for anchor",n)}},onScroll:function(){this.winScroll=!1;var n=this.win.scrollTop(),e=n+this.winHeight,t=this.navBar.scrollTop()+(n-this.winPosition);n<0||e>this.docHeight||(this.navBar.scrollTop(t),this.winPosition=n)},onResize:function(){this.winResize=!1,this.winHeight=this.win.height(),this.docHeight=$(document).height()},hashChange:function(){this.linkScroll=!0,this.win.one("hashchange",(function(){this.linkScroll=!1}))},toggleCurrent:function(n){var e=n.closest("li");e.siblings("li.current").removeClass("current").attr("aria-expanded","false"),e.siblings().find("li.current").removeClass("current").attr("aria-expanded","false");var t=e.find("> ul li");t.length&&(t.removeClass("current").attr("aria-expanded","false"),e.toggleClass("current").attr("aria-expanded",(function(n,e){return"true"==e?"false":"true"})))}},"undefined"!=typeof window&&(window.SphinxRtdTheme={Navigation:n.exports.ThemeNav,StickyNav:n.exports.ThemeNav}),function(){for(var n=0,e=["ms","moz","webkit","o"],t=0;t 2 | 3 | 4 | 5 | 6 | Search — RLZero documentation 7 | 8 | 9 | 10 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 55 | 56 |
60 | 61 |
62 |
63 |
64 |
    65 |
  • »
  • 66 |
  • Search
  • 67 |
  • 68 |
  • 69 |
70 |
71 |
72 |
73 |
74 | 75 | 82 | 83 | 84 |
85 | 86 |
87 | 88 |
89 |
90 |
91 | 92 |
93 | 94 |
95 |

© Copyright 2021, Richard Smith.

96 |
97 | 98 | Built with Sphinx using a 99 | theme 100 | provided by Read the Docs. 101 | 102 | 103 |
104 |
105 |
106 |
107 |
108 | 113 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /examples/10_lines_circles.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | def draw(): 7 | draw_circle_lines(250, 250, 50, WHITE) 8 | draw_circle(250, 100, 50, RED) 9 | draw_line(150, 20, 150, 450, PURPLE) 10 | draw_line(150, 20, 350, 20, PURPLE) 11 | 12 | run() -------------------------------------------------------------------------------- /examples/11_moving_boxes.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | box = Rectangle(20, 20, 50, 50) 7 | 8 | 9 | def draw(): 10 | draw_rectangle_rec(box, RED) 11 | 12 | def update(): 13 | box.x = box.x + 2 14 | if box.x > WIDTH: 15 | box.x = 0 16 | 17 | run() -------------------------------------------------------------------------------- /examples/12_sprites.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | alan = Sprite('alien.png') 7 | alan.x = 50 8 | alan.y = 100 9 | 10 | 11 | def draw(): 12 | alan.draw() 13 | 14 | 15 | def update(): 16 | alan.x += 1 17 | if alan.x > WIDTH: 18 | alan.x = 0 19 | 20 | run() 21 | 22 | -------------------------------------------------------------------------------- /examples/12b_background.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | alan = Sprite('alien.png') 7 | alan.x = 0 8 | alan.y = 50 9 | 10 | background = Sprite('background.png') 11 | 12 | def draw(): 13 | background.draw() 14 | alan.draw() 15 | 16 | 17 | def update(): 18 | alan.x += 2 19 | if alan.x > WIDTH: 20 | alan.x = 0 21 | 22 | run() 23 | 24 | -------------------------------------------------------------------------------- /examples/13_keyboard_input.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | alan = Sprite('alien.png') 4 | alan.pos = (0, 50) 5 | 6 | def draw(): 7 | alan.draw() 8 | 9 | def update(): 10 | if keyboard.right: 11 | alan.x = alan.x + 2 12 | elif keyboard.left: 13 | alan.x = alan.x - 2 14 | 15 | run() -------------------------------------------------------------------------------- /examples/14_joystick_input.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | alan = Sprite('alien.png') 4 | alan.pos = (0, 50) 5 | 6 | def draw(): 7 | alan.draw() 8 | 9 | def update(): 10 | if keyboard.right or gamepad.right: 11 | alan.x = alan.x + 2 12 | elif keyboard.left or gamepad.left: 13 | alan.x = alan.x - 2 14 | 15 | run() 16 | 17 | -------------------------------------------------------------------------------- /examples/15_collisions.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | alan = Sprite('alien.png') 7 | alan.pos = (400, 50) 8 | box = Rectangle(20, 20, 100, 100) 9 | 10 | def draw(): 11 | draw_rectangle_rec(box, RED) 12 | alan.draw() 13 | 14 | def update(): 15 | if keyboard.right: 16 | alan.x = alan.x + 2 17 | elif keyboard.left: 18 | alan.x = alan.x - 2 19 | box.x = box.x + 2 20 | if box.x > WIDTH: 21 | box.x = 0 22 | if alan.colliderect(box): 23 | print("hit") 24 | 25 | 26 | run() 27 | 28 | -------------------------------------------------------------------------------- /examples/15b_chase.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | alan = Sprite("alien.png") 7 | alan.pos = (400, 50) 8 | box = Rectangle(20, 20, 100, 100) 9 | 10 | def draw(): 11 | draw_rectangle_rec(box, RED) 12 | alan.draw() 13 | 14 | def update(): 15 | if keyboard.right: 16 | alan.x = alan.x + 2 17 | elif keyboard.left: 18 | alan.x = alan.x - 2 19 | if box.x < alan.x: 20 | box.x = box.x + 1 21 | if box.x > alan.x: 22 | box.x = box.x - 1 23 | if alan.colliderect(box): 24 | exit() 25 | 26 | run() -------------------------------------------------------------------------------- /examples/15c_powerup.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | import random 3 | 4 | WIDTH = 500 5 | HEIGHT = 500 6 | 7 | alan = Sprite("alien.png") 8 | alan.pos = (400, 50) 9 | box = Rectangle(20, 20, 100, 100) 10 | score = 0 11 | 12 | def draw(): 13 | draw_rectangle_rec(box, GREEN) 14 | alan.draw() 15 | 16 | def update(): 17 | global score 18 | if keyboard.right: 19 | alan.x = alan.x + 2 20 | elif keyboard.left: 21 | alan.x = alan.x - 2 22 | if alan.colliderect(box): 23 | box.x = random.randint(0, WIDTH) 24 | box.y = random.randint(0, HEIGHT) 25 | score = score + 1 26 | print("Score:", score) 27 | 28 | run() 29 | -------------------------------------------------------------------------------- /examples/16_collisions2_sound_animation.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | alan = Sprite("alien.png") 6 | alan.pos = (0, 50) 7 | box = Rectangle(20, 20, 100, 100) 8 | eep = Sound("eep") 9 | 10 | def draw(): 11 | draw_rectangle_rec(box, RED) 12 | alan.draw() 13 | 14 | def update(): 15 | if keyboard.right: 16 | alan.x = alan.x + 2 17 | elif keyboard.left: 18 | alan.x = alan.x - 2 19 | box.x = box.x + 2 20 | if box.x > WIDTH: 21 | box.x = 0 22 | if alan.colliderect(box): 23 | alan.image_file = "alien_hurt.png" 24 | eep.play() 25 | else: 26 | alan.image_file = "alien.png" 27 | 28 | run() -------------------------------------------------------------------------------- /examples/16_sound.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | my_sound = Sound("eep.wav") 4 | 5 | def draw(): 6 | clear_background(WHITE) 7 | 8 | def update(): 9 | if keyboard.space: 10 | my_sound.play() 11 | 12 | run() -------------------------------------------------------------------------------- /examples/17_mouse_input.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | alan = Sprite("alien.png") 4 | alan.pos = (0, 50) 5 | eep = Sound("eep") 6 | 7 | score = 0 8 | 9 | def draw(): 10 | alan.draw() 11 | draw_text("Score "+str(score), 0, 0, 20, WHITE) 12 | 13 | def update(): 14 | if keyboard.right: 15 | alan.x = alan.x + 2 16 | elif keyboard.left: 17 | alan.x = alan.x - 2 18 | alan.image = 'alien.png' 19 | 20 | def on_mouse_down(pos, button): 21 | global score 22 | if button == MOUSE_BUTTON_LEFT and alan.collidepoint(pos): 23 | alan.image = 'alien_hurt.png' 24 | eep.play() 25 | score = score + 1 26 | 27 | run() 28 | 29 | -------------------------------------------------------------------------------- /examples/18_mouse_movement.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | # wiggle your mouse around the screen! 4 | 5 | alan = Sprite("alien.png") 6 | 7 | def draw(): 8 | alan.draw() 9 | 10 | def on_mouse_move(pos): 11 | alan.pos = pos 12 | 13 | run() -------------------------------------------------------------------------------- /examples/20_loops.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | def draw(): 7 | for x in range(0, WIDTH, 40): 8 | draw_circle(x, 20, 20, RED) 9 | 10 | for x in range(0, WIDTH, 40): 11 | for y in range(60, HEIGHT, 40): 12 | draw_circle(x, y, 10, GREEN) 13 | 14 | run() -------------------------------------------------------------------------------- /examples/21_arrays.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | aliens = [] 7 | for i in range(0,10): 8 | aliens.append(Sprite('alien.png', (i*30, i*30))) 9 | 10 | def draw(): 11 | for alien in aliens: 12 | alien.draw() 13 | 14 | def update(): 15 | for alien in aliens: 16 | alien.x += 2 17 | if alien.x > WIDTH: 18 | alien.x = 0 19 | 20 | def on_mouse_pressed(pos, button): 21 | aliens.append(Sprite('alien.png', pos)) 22 | 23 | run() -------------------------------------------------------------------------------- /examples/22_animation.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | alan = Sprite('alien.png') 7 | alan.pos = (200, 200) 8 | 9 | def draw(): 10 | alan.draw() 11 | 12 | def update(): 13 | if keyboard.right: 14 | alan.x = alan.x + 2 15 | elif keyboard.left: 16 | alan.x = alan.x - 2 17 | if keyboard.space: 18 | schedule_cancel(animateAlien) 19 | 20 | images = ["alien_hurt.png", "alien.png"] 21 | image_counter = 0 22 | 23 | def animateAlien(): 24 | global image_counter 25 | alan.image_file = images[image_counter % len(images)] 26 | image_counter += 1 27 | 28 | schedule_repeat(animateAlien, 0.2) 29 | 30 | run() -------------------------------------------------------------------------------- /examples/23_simple_physics.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | ball = Rectangle(200, 400, 20, 20) 7 | vx = 1 8 | vy = 1 9 | 10 | def draw(): 11 | draw_rectangle_rec(ball, RED) 12 | 13 | def update(): 14 | global vx, vy 15 | ball.x += vx 16 | ball.y += vy 17 | if ball.x > WIDTH or ball.x < 0: 18 | vx = -vx 19 | if ball.y > HEIGHT or ball.y < 0: 20 | vy = -vy 21 | 22 | run() -------------------------------------------------------------------------------- /examples/24_pong.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | ball = Rectangle(150, 400, 20, 20) 7 | bat = Rectangle(200, 480, 60, 20) 8 | vx = 4 9 | vy = 4 10 | 11 | def draw(): 12 | draw_rectangle_rec(ball, RED) 13 | draw_rectangle_rec(bat, WHITE) 14 | 15 | def update(): 16 | global vx, vy 17 | ball.x += vx 18 | ball.y += vy 19 | if ball.x > WIDTH or ball.x < 0: 20 | vx = -vx 21 | if check_collision_recs(bat, ball) or ball.y < 0: 22 | vy = -vy 23 | if ball.y > HEIGHT: 24 | exit() 25 | if(keyboard.right): 26 | bat.x += 2 27 | elif(keyboard.left): 28 | bat.x -= 2 29 | 30 | run() 31 | 32 | -------------------------------------------------------------------------------- /examples/25_colours.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | # my_colour = Color(0,0,0,255) # makes black 4 | # my_colour = Color(255,255,255,255) # makes white 5 | 6 | red_amount = 0 7 | green_amount = 0 8 | blue_amount = 0 9 | alpha_amount = 255 10 | 11 | def draw(): 12 | my_colour = Color(red_amount, green_amount, blue_amount, alpha_amount) 13 | clear_background(my_colour) 14 | 15 | # This function makes the colour change every frame 16 | # Remove it if you just want to see a static colour. 17 | def update(): 18 | global red_amount 19 | red_amount += 1 20 | red_amount = red_amount % 255 21 | 22 | run() -------------------------------------------------------------------------------- /examples/26_classes.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | 4 | WIDTH = 500 5 | HEIGHT = 500 6 | 7 | class MySprite(Sprite): 8 | vx = 1 9 | vy = 1 10 | 11 | ball = MySprite('alien.png') 12 | 13 | def draw(): 14 | clear() 15 | ball.draw() 16 | 17 | def update(): 18 | ball.x += ball.vx 19 | ball.y += ball.vy 20 | if ball.x > WIDTH or ball.x < 0: 21 | ball.vx = -ball.vx 22 | if ball.y > HEIGHT or ball.y < 0: 23 | ball.vy = -ball.vy 24 | 25 | 26 | run() -------------------------------------------------------------------------------- /examples/26_fullscreen_mode.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | alien = Sprite("alien") 7 | 8 | def draw(): 9 | clear() 10 | alien.draw() 11 | 12 | def update(): 13 | if keyboard.f1: 14 | toggle_fullscreen() 15 | if keyboard.enter: 16 | exit() 17 | 18 | run() -------------------------------------------------------------------------------- /examples/27_classes2.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | class MySprite(Sprite): 7 | vx = 1 8 | vy = 1 9 | 10 | def update(self): 11 | self.x += self.vx 12 | self.y += self.vy 13 | if self.x > WIDTH or self.x < 0: 14 | self.vx = -self.vx 15 | if self.y > HEIGHT or self.y < 0: 16 | self.vy = -self.vy 17 | 18 | ball = MySprite("alien.png") 19 | 20 | def draw(): 21 | clear() 22 | ball.draw() 23 | 24 | def update(): 25 | ball.update() 26 | 27 | run() -------------------------------------------------------------------------------- /examples/27_displaying_text.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | score = 0 7 | 8 | def draw(): 9 | clear() 10 | draw_text(f"Player 1 score: {score}", 0, 0, 20, RED) 11 | 12 | # This is another special function that is called by RLzero automatically 13 | # each time a key is pressed. That way player cannot just hold down the key! 14 | 15 | def on_key_pressed(key): 16 | global score 17 | if key == KEY_SPACE: 18 | score += 1 19 | 20 | run() -------------------------------------------------------------------------------- /examples/28_timer.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | timer = 0 4 | 5 | def update(dt): 6 | global timer 7 | timer += dt 8 | 9 | 10 | def draw(): 11 | draw_text(f"Time passed: {timer}", 0, 0, 20, RED) 12 | if timer > 5: 13 | draw_text("Time's up!", 50, 50, 40, WHITE) 14 | 15 | run() -------------------------------------------------------------------------------- /examples/29_timer2.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | import random 3 | 4 | aliens = [] 5 | 6 | def add_alien(): 7 | aliens.append( 8 | Sprite("alien", (random.randint(0,500), random.randint(0,500))) 9 | ) 10 | 11 | # call add_alien once, 0.5 seconds from now 12 | schedule_once(add_alien, 0.5) 13 | 14 | # call add_alien over and over again, ever 2 seconds 15 | schedule_repeat(add_alien, 2.0) 16 | 17 | def draw(): 18 | for alien in aliens: 19 | alien.draw() 20 | 21 | run() -------------------------------------------------------------------------------- /examples/animation.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | alien = Sprite("alien.png") 6 | animation = Animation(["alien.png","alien_hurt.png"], 5) 7 | alien.pos = (0, 50) 8 | 9 | 10 | def draw(): 11 | clear() 12 | alien.draw() 13 | 14 | def update(): 15 | if keyboard.right: 16 | alien.x = alien.x + 2 17 | elif keyboard.left: 18 | alien.x = alien.x - 2 19 | animation.update(alien) 20 | 21 | run() -------------------------------------------------------------------------------- /examples/chase_game/chase.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 600 4 | HEIGHT = 600 5 | 6 | background = Sprite("background") 7 | player = Sprite("player") 8 | player.x = 200 9 | player.y = 200 10 | score = 0 11 | 12 | badguy = Sprite("badguy") 13 | 14 | eep = Sound("eep.wav") 15 | 16 | def draw(): 17 | clear() 18 | background.draw() 19 | player.draw() 20 | badguy.draw() 21 | draw_text(f"score: {score}", 0, 0, 20, RED) 22 | 23 | def update(): 24 | global score 25 | if keyboard.right: 26 | player.x = player.x + 6 27 | if keyboard.left: 28 | player.x = player.x - 6 29 | if keyboard.down: 30 | player.y = player.y + 6 31 | if keyboard.up: 32 | player.y = player.y - 6 33 | 34 | if keyboard.d: 35 | badguy.x = badguy.x + 5 36 | if keyboard.a: 37 | badguy.x = badguy.x - 5 38 | if keyboard.s: 39 | badguy.y = badguy.y + 5 40 | if keyboard.w: 41 | badguy.y = badguy.y - 5 42 | 43 | if player.x > 600: 44 | player.x = 0 45 | if player.x < -36: 46 | player.x = 600 47 | if player.y < -36: 48 | player.y = 600 49 | if player.y > 636: 50 | player.y = 0 51 | 52 | print(player.x, player.y) 53 | 54 | if badguy.x > 600: 55 | badguy.x = 0 56 | if badguy.x < -36: 57 | badguy.x = 600 58 | if badguy.y < -36: 59 | badguy.y = 600 60 | if badguy.y > 636: 61 | badguy.y = 0 62 | 63 | if badguy.colliderect(player): 64 | eep.play() 65 | 66 | run() 67 | -------------------------------------------------------------------------------- /examples/chase_game/chase1.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 600 4 | HEIGHT = 600 5 | 6 | background = Sprite("background") 7 | player = Sprite("player") 8 | player.x = 200 9 | player.y = 200 10 | 11 | def draw(): 12 | clear() 13 | background.draw() 14 | player.draw() 15 | 16 | def update(): 17 | if keyboard.right: 18 | player.x = player.x + 4 19 | if keyboard.left: 20 | player.x = player.x - 4 21 | if keyboard.down: 22 | player.y = player.y + 4 23 | if keyboard.up: 24 | player.y = player.y - 4 25 | 26 | run() 27 | -------------------------------------------------------------------------------- /examples/chase_game/chase2.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 600 4 | HEIGHT = 600 5 | 6 | background = Sprite("background") 7 | player = Sprite("player") 8 | player.x = 200 9 | player.y = 200 10 | 11 | 12 | def draw(): 13 | clear() 14 | background.draw() 15 | player.draw() 16 | 17 | 18 | 19 | def update(): 20 | global score 21 | if keyboard.right: 22 | player.x = player.x + 4 23 | if keyboard.left: 24 | player.x = player.x - 4 25 | if keyboard.down: 26 | player.y = player.y + 4 27 | if keyboard.up: 28 | player.y = player.y - 4 29 | 30 | if player.x > WIDTH: 31 | player.x = 0 32 | if player.x < 0: 33 | player.x = WIDTH 34 | if player.y < 0: 35 | player.y = HEIGHT 36 | if player.y > HEIGHT: 37 | player.y = 0 38 | 39 | run() 40 | 41 | 42 | -------------------------------------------------------------------------------- /examples/chase_game/chaser3.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 600 4 | HEIGHT = 600 5 | 6 | background = Sprite("background") 7 | player = Sprite("player") 8 | player.x = 200 9 | player.y = 200 10 | 11 | enemy = Sprite("alien") 12 | 13 | def draw(): 14 | clear() 15 | background.draw() 16 | player.draw() 17 | enemy.draw() 18 | 19 | 20 | def update(): 21 | global score 22 | if keyboard.right: 23 | player.x = player.x + 4 24 | if keyboard.left: 25 | player.x = player.x - 4 26 | if keyboard.down: 27 | player.y = player.y + 4 28 | if keyboard.up: 29 | player.y = player.y - 4 30 | 31 | if player.x > WIDTH: 32 | player.x = 0 33 | if player.x < 0: 34 | player.x = WIDTH 35 | if player.y < 0: 36 | player.y = HEIGHT 37 | if player.y > HEIGHT: 38 | player.y = 0 39 | 40 | if enemy.x < player.x: 41 | enemy.x = enemy.x + 1 42 | if enemy.x > player.x: 43 | enemy.x = enemy.x - 1 44 | if enemy.y < player.y: 45 | enemy.y = enemy.y + 1 46 | if enemy.y > player.y: 47 | enemy.y = enemy.y - 1 48 | if player.colliderect(enemy): 49 | exit() 50 | 51 | run() 52 | 53 | -------------------------------------------------------------------------------- /examples/chase_game/chaser4.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 600 4 | HEIGHT = 600 5 | 6 | background = Sprite("background") 7 | player = Sprite("player") 8 | player.x = 200 9 | player.y = 200 10 | 11 | enemy = Sprite("alien") 12 | player2 = Sprite("player") 13 | 14 | def draw(): 15 | clear() 16 | background.draw() 17 | player.draw() 18 | enemy.draw() 19 | player2.draw() 20 | 21 | def update(): 22 | global score 23 | if keyboard.right: 24 | player.x = player.x + 4 25 | if keyboard.left: 26 | player.x = player.x - 4 27 | if keyboard.down: 28 | player.y = player.y + 4 29 | if keyboard.up: 30 | player.y = player.y - 4 31 | 32 | if player.x > WIDTH: 33 | player.x = 0 34 | if player.x < 0: 35 | player.x = WIDTH 36 | if player.y < 0: 37 | player.y = HEIGHT 38 | if player.y > HEIGHT: 39 | player.y = 0 40 | 41 | if enemy.x < player.x: 42 | enemy.x = enemy.x + 1 43 | if enemy.x > player.x: 44 | enemy.x = enemy.x - 1 45 | if enemy.y < player.y: 46 | enemy.y = enemy.y + 1 47 | if enemy.y > player.y: 48 | enemy.y = enemy.y - 1 49 | if player.colliderect(enemy): 50 | exit() 51 | 52 | if keyboard.d: 53 | player2.x = player2.x + 4 54 | if keyboard.a: 55 | player2.x = player2.x - 4 56 | if keyboard.s: 57 | player2.y = player2.y + 4 58 | if keyboard.w: 59 | player2.y = player2.y - 4 60 | if player.colliderect(player2): 61 | exit() 62 | 63 | run() -------------------------------------------------------------------------------- /examples/chase_game/chaser5.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | import random 3 | 4 | WIDTH = 600 5 | HEIGHT = 600 6 | 7 | background = Sprite("background") 8 | player = Sprite("player") 9 | player.x = 200 10 | player.y = 200 11 | 12 | enemy = Sprite("alien") 13 | player2 = Sprite("player") 14 | coin = Sprite("alien", pos=(300,300)) 15 | score = 0 16 | 17 | def draw(): 18 | clear() 19 | background.draw() 20 | player.draw() 21 | enemy.draw() 22 | player2.draw() 23 | coin.draw() 24 | 25 | def update(): 26 | global score 27 | if keyboard.right: 28 | player.x = player.x + 4 29 | if keyboard.left: 30 | player.x = player.x - 4 31 | if keyboard.down: 32 | player.y = player.y + 4 33 | if keyboard.up: 34 | player.y = player.y - 4 35 | 36 | if player.x > WIDTH: 37 | player.x = 0 38 | if player.x < 0: 39 | player.x = WIDTH 40 | if player.y < 0: 41 | player.y = HEIGHT 42 | if player.y > HEIGHT: 43 | player.y = 0 44 | 45 | if enemy.x < player.x: 46 | enemy.x = enemy.x + 1 47 | if enemy.x > player.x: 48 | enemy.x = enemy.x - 1 49 | if enemy.y < player.y: 50 | enemy.y = enemy.y + 1 51 | if enemy.y > player.y: 52 | enemy.y = enemy.y - 1 53 | if player.colliderect(enemy): 54 | exit() 55 | 56 | if keyboard.d: 57 | player2.x = player2.x + 4 58 | if keyboard.a: 59 | player2.x = player2.x - 4 60 | if keyboard.s: 61 | player2.y = player2.y + 4 62 | if keyboard.w: 63 | player2.y = player2.y - 4 64 | if player.colliderect(player2): 65 | exit() 66 | 67 | if coin.colliderect(player): 68 | coin.x = random.randint(0, WIDTH) 69 | coin.y = random.randint(0, HEIGHT) 70 | score = score + 1 71 | print("Score:", score) 72 | 73 | run() 74 | 75 | -------------------------------------------------------------------------------- /examples/chase_game/chaser6.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | import random 3 | 4 | WIDTH = 600 5 | HEIGHT = 600 6 | 7 | background = Sprite("background") 8 | player = Sprite("player") 9 | player.x = 200 10 | player.y = 200 11 | 12 | enemy = Sprite("alien") 13 | player2 = Sprite("player") 14 | coin = Sprite("alien", pos=(300,300)) 15 | score = 0 16 | 17 | def draw(): 18 | clear() 19 | background.draw() 20 | player.draw() 21 | enemy.draw() 22 | player2.draw() 23 | coin.draw() 24 | draw_text("My game", 200, 0, 20, RED) 25 | score_string = str(score) 26 | draw_text(score_string, 0,0, 20, GREEN) 27 | 28 | 29 | def update(): 30 | global score 31 | if keyboard.right: 32 | player.x = player.x + 4 33 | if keyboard.left: 34 | player.x = player.x - 4 35 | if keyboard.down: 36 | player.y = player.y + 4 37 | if keyboard.up: 38 | player.y = player.y - 4 39 | 40 | if player.x > WIDTH: 41 | player.x = 0 42 | if player.x < 0: 43 | player.x = WIDTH 44 | if player.y < 0: 45 | player.y = HEIGHT 46 | if player.y > HEIGHT: 47 | player.y = 0 48 | 49 | if enemy.x < player.x: 50 | enemy.x = enemy.x + 1 51 | if enemy.x > player.x: 52 | enemy.x = enemy.x - 1 53 | if enemy.y < player.y: 54 | enemy.y = enemy.y + 1 55 | if enemy.y > player.y: 56 | enemy.y = enemy.y - 1 57 | if player.colliderect(enemy): 58 | exit() 59 | 60 | if keyboard.d: 61 | player2.x = player2.x + 4 62 | if keyboard.a: 63 | player2.x = player2.x - 4 64 | if keyboard.s: 65 | player2.y = player2.y + 4 66 | if keyboard.w: 67 | player2.y = player2.y - 4 68 | if player.colliderect(player2): 69 | exit() 70 | 71 | if coin.colliderect(player): 72 | coin.x = random.randint(0, WIDTH) 73 | coin.y = random.randint(0, HEIGHT) 74 | score = score + 1 75 | print("Score:", score) 76 | 77 | run() -------------------------------------------------------------------------------- /examples/chase_game/chaser7.py: -------------------------------------------------------------------------------- 1 | import random 2 | from rlzero import * 3 | 4 | WIDTH = 600 5 | HEIGHT = 600 6 | 7 | background = Sprite("background") 8 | player = Sprite("player") 9 | player.x = 200 10 | player.y = 200 11 | 12 | enemy = Sprite("alien") 13 | player2 = Sprite("player") 14 | coin = Sprite("coin", pos=(300,300)) 15 | score = 0 16 | time = 20 17 | 18 | 19 | def draw2d(): 20 | clear() 21 | background.draw() 22 | player.draw() 23 | enemy.draw() 24 | player2.draw() 25 | coin.draw() 26 | draw_text("My game", 200, 0, 20, RED) 27 | score_string = str(score) 28 | draw_text(score_string, 0,0, 20, GREEN) 29 | time_string = str(round(time)) 30 | draw_text(time_string, 50,0, 20, GREEN) 31 | 32 | def update(delta): 33 | global score, time 34 | time = time - delta 35 | if time <= 0: 36 | print("time out") 37 | exit() 38 | if keyboard.right: 39 | player.x = player.x + 4 40 | if keyboard.left: 41 | player.x = player.x - 4 42 | if keyboard.down: 43 | player.y = player.y + 4 44 | if keyboard.up: 45 | player.y = player.y - 4 46 | 47 | if player.x > WIDTH: 48 | player.x = 0 49 | if player.x < 0: 50 | player.x = WIDTH 51 | if player.y < 0: 52 | player.y = HEIGHT 53 | if player.y > HEIGHT: 54 | player.y = 0 55 | 56 | if enemy.x < player.x: 57 | enemy.x = enemy.x + 1 58 | if enemy.x > player.x: 59 | enemy.x = enemy.x - 1 60 | if enemy.y < player.y: 61 | enemy.y = enemy.y + 1 62 | if enemy.y > player.y: 63 | enemy.y = enemy.y - 1 64 | if player.colliderect(enemy): 65 | print("player 1 hit enemy") 66 | exit() 67 | 68 | if keyboard.d: 69 | player2.x = player2.x + 4 70 | if keyboard.a: 71 | player2.x = player2.x - 4 72 | if keyboard.s: 73 | player2.y = player2.y + 4 74 | if keyboard.w: 75 | player2.y = player2.y - 4 76 | if player.colliderect(player2): 77 | print("player1 hit player 2") 78 | exit() 79 | 80 | if coin.colliderect(player): 81 | coin.x = random.randint(0, WIDTH) 82 | coin.y = random.randint(0, HEIGHT) 83 | score = score + 1 84 | print("Score:", score) 85 | 86 | 87 | run() -------------------------------------------------------------------------------- /examples/chase_game/coin.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/coin.png -------------------------------------------------------------------------------- /examples/chase_game/images/alien.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/alien.png -------------------------------------------------------------------------------- /examples/chase_game/images/alien_hurt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/alien_hurt.png -------------------------------------------------------------------------------- /examples/chase_game/images/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/background.png -------------------------------------------------------------------------------- /examples/chase_game/images/badguy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/badguy.png -------------------------------------------------------------------------------- /examples/chase_game/images/cat1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/cat1.png -------------------------------------------------------------------------------- /examples/chase_game/images/cat2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/cat2.png -------------------------------------------------------------------------------- /examples/chase_game/images/cat3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/cat3.png -------------------------------------------------------------------------------- /examples/chase_game/images/cat4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/cat4.png -------------------------------------------------------------------------------- /examples/chase_game/images/door.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/door.png -------------------------------------------------------------------------------- /examples/chase_game/images/empty0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/empty0.png -------------------------------------------------------------------------------- /examples/chase_game/images/goal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/goal.png -------------------------------------------------------------------------------- /examples/chase_game/images/goal2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/goal2.png -------------------------------------------------------------------------------- /examples/chase_game/images/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/key.png -------------------------------------------------------------------------------- /examples/chase_game/images/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/player.png -------------------------------------------------------------------------------- /examples/chase_game/images/splat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/splat.png -------------------------------------------------------------------------------- /examples/chase_game/images/wall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/wall.png -------------------------------------------------------------------------------- /examples/chase_game/images/wall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/chase_game/images/wall1.png -------------------------------------------------------------------------------- /examples/custom_main_loop.py: -------------------------------------------------------------------------------- 1 | """ 2 | You can write your own main loop rather than rely on rlzero to magically provide 3 | one. 4 | """ 5 | from rlzero import * 6 | 7 | cube = Cube((0, 10, 0), (10, 20, 10), BLUE) 8 | pr.set_window_size(800, 500, "title") 9 | camera = pr.Camera3D([18.0, 16.0, 18.0], [0.0, 0.0, 0.0], [0.0, 1.0, 0.0], 45.0, 0) 10 | pr.set_camera_mode(camera, pr.CAMERA_FIRST_PERSON) 11 | 12 | while not pr.window_should_close(): 13 | 14 | pr.update_camera(camera) 15 | cube.x = cube.x + 1 16 | if cube.x > 100: 17 | cube.x = -100 18 | 19 | if pr.is_key_pressed(pr.KEY_ESCAPE): 20 | exit() 21 | 22 | pr.begin_drawing() 23 | pr.begin_mode_3d(camera) 24 | pr.draw_grid(100, 10) 25 | clear() 26 | cube.draw() 27 | pr.end_mode_3d() 28 | pr.end_drawing() 29 | 30 | -------------------------------------------------------------------------------- /examples/data/images/alien.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/alien.png -------------------------------------------------------------------------------- /examples/data/images/alien_hurt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/alien_hurt.png -------------------------------------------------------------------------------- /examples/data/images/background.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/background.png -------------------------------------------------------------------------------- /examples/data/images/badguy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/badguy.png -------------------------------------------------------------------------------- /examples/data/images/cat1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/cat1.png -------------------------------------------------------------------------------- /examples/data/images/cat2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/cat2.png -------------------------------------------------------------------------------- /examples/data/images/cat3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/cat3.png -------------------------------------------------------------------------------- /examples/data/images/cat4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/cat4.png -------------------------------------------------------------------------------- /examples/data/images/door.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/door.png -------------------------------------------------------------------------------- /examples/data/images/empty0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/empty0.png -------------------------------------------------------------------------------- /examples/data/images/goal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/goal.png -------------------------------------------------------------------------------- /examples/data/images/goal2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/goal2.png -------------------------------------------------------------------------------- /examples/data/images/key.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/key.png -------------------------------------------------------------------------------- /examples/data/images/player.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/player.png -------------------------------------------------------------------------------- /examples/data/images/splat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/splat.png -------------------------------------------------------------------------------- /examples/data/images/wall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/wall.png -------------------------------------------------------------------------------- /examples/data/images/wall1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/images/wall1.png -------------------------------------------------------------------------------- /examples/data/models/__init__.py: -------------------------------------------------------------------------------- 1 | __version__ = "0.1.0" 2 | 3 | -------------------------------------------------------------------------------- /examples/data/models/characters/BlueSoldier_Female.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/BlueSoldier_Female.glb -------------------------------------------------------------------------------- /examples/data/models/characters/BlueSoldier_Male.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/BlueSoldier_Male.glb -------------------------------------------------------------------------------- /examples/data/models/characters/Casual2_Female.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/Casual2_Female.glb -------------------------------------------------------------------------------- /examples/data/models/characters/Casual2_Male.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/Casual2_Male.glb -------------------------------------------------------------------------------- /examples/data/models/characters/License.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------ 2 | LowPoly Models by @Quaternius 3 | Consider supporting me on Patreon, even $1 helps me a lot! 4 | 5 | https://www.patreon.com/quaternius 6 | ------------------------------------------------------- 7 | 8 | License: 9 | CC0 1.0 Universal (CC0 1.0) 10 | Public Domain Dedication 11 | https://creativecommons.org/publicdomain/zero/1.0/ 12 | 13 | -------------------------------------------------------------------------------- /examples/data/models/characters/Worker_Female.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/Worker_Female.glb -------------------------------------------------------------------------------- /examples/data/models/characters/Worker_Male.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/Worker_Male.glb -------------------------------------------------------------------------------- /examples/data/models/characters/Zombie_Female.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/Zombie_Female.glb -------------------------------------------------------------------------------- /examples/data/models/characters/Zombie_Male.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/characters/Zombie_Male.glb -------------------------------------------------------------------------------- /examples/data/models/monsters/Bat.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Bat.glb -------------------------------------------------------------------------------- /examples/data/models/monsters/Belly.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Belly.material -------------------------------------------------------------------------------- /examples/data/models/monsters/Black.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Black.material -------------------------------------------------------------------------------- /examples/data/models/monsters/Body.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Body.material -------------------------------------------------------------------------------- /examples/data/models/monsters/Claws.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Claws.material -------------------------------------------------------------------------------- /examples/data/models/monsters/Dragon.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Dragon.glb -------------------------------------------------------------------------------- /examples/data/models/monsters/Eyes.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Eyes.material -------------------------------------------------------------------------------- /examples/data/models/monsters/License.txt: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------ 2 | Animated Monsters by Quaternius 3 | Consider supporting me on Patreon, even $1 helps me a lot! 4 | 5 | https://www.patreon.com/quaternius 6 | ------------------------------------------------------- 7 | 8 | License: 9 | CC0 1.0 Universal (CC0 1.0) 10 | Public Domain Dedication 11 | https://creativecommons.org/publicdomain/zero/1.0/ 12 | 13 | ------------------------------------------------------- 14 | If you want to credit me just say: 15 | Animated Monsters by Quaternius 16 | https://www.patreon.com/quaternius 17 | -------------------------------------------------------------------------------- /examples/data/models/monsters/Main.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Main.material -------------------------------------------------------------------------------- /examples/data/models/monsters/Nose.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Nose.material -------------------------------------------------------------------------------- /examples/data/models/monsters/Skeleton.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Skeleton.glb -------------------------------------------------------------------------------- /examples/data/models/monsters/Slime.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Slime.glb -------------------------------------------------------------------------------- /examples/data/models/monsters/Wings.material: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/monsters/Wings.material -------------------------------------------------------------------------------- /examples/data/models/rpg_characters/Cleric.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/rpg_characters/Cleric.glb -------------------------------------------------------------------------------- /examples/data/models/rpg_characters/Monk.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/rpg_characters/Monk.glb -------------------------------------------------------------------------------- /examples/data/models/rpg_characters/Ranger.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/rpg_characters/Ranger.glb -------------------------------------------------------------------------------- /examples/data/models/rpg_characters/Rogue.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/rpg_characters/Rogue.glb -------------------------------------------------------------------------------- /examples/data/models/rpg_characters/Warrior.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/rpg_characters/Warrior.glb -------------------------------------------------------------------------------- /examples/data/models/rpg_characters/Wizard.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/models/rpg_characters/Wizard.glb -------------------------------------------------------------------------------- /examples/data/sounds/eep.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/examples/data/sounds/eep.wav -------------------------------------------------------------------------------- /examples/mand.py: -------------------------------------------------------------------------------- 1 | import pyray as rl 2 | 3 | 4 | WIDTH = 1920 5 | HEIGHT = 1080 6 | 7 | # Plot window 8 | RE_START = -2 9 | RE_END = 1 10 | IM_START = -1 11 | IM_END = 1 12 | 13 | MAX_ITER = 80 14 | 15 | palette = [] 16 | 17 | rl.init_window(WIDTH, HEIGHT, "Mandlebrot") 18 | rl.set_target_fps(60) 19 | 20 | def mandelbrot(c): 21 | z = 0 22 | n = 0 23 | while abs(z) <= 2 and n < MAX_ITER: 24 | z = z*z + c 25 | n += 1 26 | return n 27 | 28 | 29 | def draw(): 30 | for x in range(0, WIDTH): 31 | for y in range(0, HEIGHT): 32 | # Convert pixel coordinate to complex number 33 | c = complex(RE_START + (x / WIDTH) * (RE_END - RE_START), 34 | IM_START + (y / HEIGHT) * (IM_END - IM_START)) 35 | # Compute the number of iterations 36 | m = mandelbrot(c) 37 | # The color depends on the number of iterations 38 | bw = 255 - int(m * 255 / MAX_ITER) 39 | color = (bw, bw, bw, 255) 40 | 41 | hue = int(255 * m / MAX_ITER) 42 | saturation = 255 43 | value = 255 if m < MAX_ITER else 0 44 | color = rl.color_from_hsv(hue, saturation, value) 45 | 46 | # Plot the point 47 | rl.draw_pixel(x, y, color) 48 | 49 | 50 | while not rl.window_should_close(): 51 | rl.begin_drawing() 52 | draw() 53 | rl.end_drawing() 54 | 55 | 56 | -------------------------------------------------------------------------------- /examples/mand2.py: -------------------------------------------------------------------------------- 1 | import pyray as pr 2 | from raylib import * 3 | # from math import log, log2 4 | import threading 5 | 6 | WIDTH = 1920 7 | HEIGHT = 1080 8 | 9 | # Plot window 10 | RE_START = -2 11 | RE_END = 1 12 | IM_START = -1 13 | IM_END = 1 14 | 15 | RE_WIDTH = (RE_END - RE_START) 16 | IM_HEIGHT = (IM_END - IM_START) 17 | 18 | MAX_ITER = 80 19 | 20 | zoom = 1.0 21 | 22 | scale = 4 23 | 24 | palette = [] 25 | 26 | rl.init_window(WIDTH, HEIGHT, "Mandlebrot") 27 | rl.set_target_fps(60) 28 | 29 | image = rl.gen_image_color(WIDTH, HEIGHT, (0,0,0,255) ) 30 | texture = rl.load_texture_from_image(image) 31 | rl.set_texture_filter(texture, TEXTURE_FILTER_BILINEAR) 32 | 33 | def mandelbrot(c): 34 | z = 0 35 | n = 0 36 | while abs(z) <= 2 and n < MAX_ITER: 37 | z = z*z + c 38 | n += 1 39 | return n 40 | #if n == MAX_ITER: 41 | # return MAX_ITER 42 | 43 | #return n + 1 - log(log2(abs(z))) 44 | 45 | stop = False 46 | 47 | def draw(): 48 | for x in range(0, WIDTH//scale): 49 | for y in range(0, HEIGHT//scale): 50 | # Convert pixel coordinate to complex number 51 | c = complex((RE_START + (x / (WIDTH//scale)) * (RE_WIDTH))*zoom, 52 | (IM_START + (y / (HEIGHT//scale)) * (IM_HEIGHT))*zoom) 53 | # Compute the number of iterations 54 | m = mandelbrot(c) 55 | # The color depends on the number of iterations 56 | bw = 255 - int(m * 255 / MAX_ITER) 57 | color = (bw, bw, bw, 255) 58 | 59 | hue = int(255 * m / MAX_ITER) 60 | saturation = 255 61 | value = 255 if m < MAX_ITER else 0 62 | color = rl.color_from_hsv(hue, saturation, value) 63 | 64 | # Plot the point 65 | rl.image_draw_pixel(image, x, y, color) 66 | if stop: 67 | return 68 | 69 | 70 | def redraw(): 71 | draw() 72 | # global thread 73 | # stop = True 74 | # thread.join() 75 | # stop = False 76 | # thread = threading.Thread(target=draw) 77 | # thread.start() 78 | 79 | thread = threading.Thread(target=draw) 80 | thread.start() 81 | 82 | draw() 83 | 84 | while not rl.window_should_close(): 85 | rl.begin_drawing() 86 | 87 | UpdateTexture(texture, image.data) 88 | #rl.update_texture(texture, image.data[0]) 89 | #rl.draw_texture(texture, 0, 0, (255,255,255,255)) 90 | rl.draw_texture_ex(texture, (0,0), 0, scale, (255,255,255,255)) 91 | rl.end_drawing() 92 | 93 | if rl.is_key_pressed(KEY_SPACE): 94 | zoom = zoom * 1.2 95 | redraw() 96 | elif rl.is_key_pressed(KEY_ENTER): 97 | zoom = zoom * 0.8 98 | redraw() 99 | elif rl.is_key_pressed(KEY_UP): 100 | IM_START -= 0.2 101 | redraw() 102 | elif rl.is_key_pressed(KEY_DOWN): 103 | IM_START += 0.2 104 | redraw() 105 | elif rl.is_key_pressed(KEY_LEFT): 106 | RE_START -= 0.2 107 | redraw() 108 | elif rl.is_key_pressed(KEY_RIGHT): 109 | RE_START += 0.2 110 | redraw() 111 | elif rl.is_key_pressed(KEY_Z): 112 | scale = 1 113 | redraw() 114 | elif rl.is_key_pressed(KEY_X): 115 | scale = 4 116 | redraw() 117 | 118 | -------------------------------------------------------------------------------- /examples/mand3.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 1920 4 | HEIGHT = 1080 5 | 6 | RE_START = -2 7 | RE_END = 1 8 | IM_START = -1 9 | IM_END = 1 10 | 11 | RE_WIDTH = (RE_END - RE_START) 12 | IM_HEIGHT = (IM_END - IM_START) 13 | 14 | MAX_ITER = 80 15 | 16 | zoom = 1.0 17 | 18 | SCALE = 4 19 | 20 | 21 | 22 | 23 | def mandelbrot(c): 24 | z = 0 25 | n = 0 26 | while abs(z) <= 2 and n < MAX_ITER: 27 | z = z*z + c 28 | n += 1 29 | return n 30 | 31 | 32 | def plot_image(): 33 | for x in range(0, WIDTH//SCALE): 34 | for y in range(0, HEIGHT//SCALE): 35 | # Convert pixel coordinate to complex number 36 | c = complex((RE_START + (x / (WIDTH//SCALE)) * RE_WIDTH) * zoom, 37 | (IM_START + (y / (HEIGHT//SCALE)) * IM_HEIGHT) * zoom) 38 | # Compute the number of iterations 39 | m = mandelbrot(c) 40 | # The color depends on the number of iterations 41 | bw = 255 - int(m * 255 / MAX_ITER) 42 | color = (bw, bw, bw, 255) 43 | 44 | hue = int(255 * m / MAX_ITER) 45 | saturation = 255 46 | value = 255 if m < MAX_ITER else 0 47 | color = pyray.color_from_hsv(hue, saturation, value) 48 | 49 | # Plot the point 50 | pyray.image_draw_pixel(image, x, y, color) 51 | 52 | 53 | 54 | image = pyray.gen_image_color(WIDTH, HEIGHT, GREEN) 55 | plot_image() 56 | 57 | 58 | def init(): 59 | global texture 60 | texture = pyray.load_texture_from_image(image) 61 | pyray.set_texture_filter(texture, pyray.TEXTURE_FILTER_BILINEAR) 62 | 63 | 64 | 65 | def draw2d(): 66 | pyray.draw_texture_ex(texture, (0,0), 0, SCALE, WHITE) 67 | 68 | 69 | def update(): 70 | global zoom, IM_START, RE_START 71 | rl.UpdateTexture(texture, image.data) 72 | if keyboard.space: 73 | zoom = zoom * 1.2 74 | plot_image() 75 | elif keyboard.enter: 76 | zoom = zoom * 0.8 77 | plot_image() 78 | elif keyboard.up: 79 | IM_START -= 0.2 80 | plot_image() 81 | elif keyboard.down: 82 | IM_START += 0.2 83 | plot_image() 84 | elif keyboard.left: 85 | RE_START -= 0.2 86 | plot_image() 87 | elif keyboard.right: 88 | RE_START += 0.2 89 | plot_image() 90 | 91 | run() 92 | 93 | -------------------------------------------------------------------------------- /examples/mand4.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | 14 | def mandelbrot(c): 15 | z = 0 16 | n = 0 17 | while abs(z) <= 2 and n < MAX_ITER: 18 | z = z * z + c 19 | n += 1 20 | return n 21 | 22 | 23 | def plot_image(): 24 | for x in range(0, WIDTH): 25 | for y in range(0, HEIGHT): 26 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH), 27 | (IM_START + (y / HEIGHT) * IM_HEIGHT)) 28 | m = mandelbrot(c) 29 | hue = int(255 * m / MAX_ITER) 30 | saturation = 255 31 | value = 255 if m < MAX_ITER else 0 32 | color = pyray.color_from_hsv(hue, saturation, value) 33 | screen.image_draw_pixel(image, x, y, color) 34 | 35 | 36 | image = screen.gen_image_color(WIDTH, HEIGHT, GREEN) 37 | plot_image() 38 | 39 | 40 | def init(): 41 | global texture 42 | texture = screen.load_texture_from_image(image) 43 | screen.set_texture_filter(texture, screen.TEXTURE_FILTER_BILINEAR) 44 | 45 | 46 | def draw2d(): 47 | screen.draw_texture_ex(texture, (0, 0), 0, 1, WHITE) 48 | 49 | 50 | run() 51 | -------------------------------------------------------------------------------- /examples/mand5.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | 14 | def mandelbrot(c): 15 | z = 0 16 | n = 0 17 | while abs(z) <= 2 and n < MAX_ITER: 18 | z = z * z + c 19 | n += 1 20 | return n 21 | 22 | 23 | def draw2d(): 24 | for x in range(0, WIDTH): 25 | for y in range(0, HEIGHT): 26 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH), 27 | (IM_START + (y / HEIGHT) * IM_HEIGHT)) 28 | m = mandelbrot(c) 29 | i = 255 - int(255 * m / MAX_ITER) 30 | color = (i, i, i, 255) 31 | screen.draw_pixel(x, y, color) 32 | 33 | 34 | run() 35 | -------------------------------------------------------------------------------- /examples/mand5b.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | 14 | def mandelbrot(c): 15 | z = 0 16 | n = 0 17 | while abs(z) <= 2 and n < MAX_ITER: 18 | z = z * z + c 19 | n += 1 20 | return n 21 | 22 | 23 | def draw2d(): 24 | for x in range(0, WIDTH): 25 | for y in range(0, HEIGHT): 26 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH), 27 | (IM_START + (y / HEIGHT) * IM_HEIGHT)) 28 | m = mandelbrot(c) 29 | hue = int(255 * m / MAX_ITER) 30 | saturation = 255 31 | value = 255 if m < MAX_ITER else 0 32 | color = screen.color_from_hsv(hue, saturation, value) 33 | screen.draw_pixel(x, y, color) 34 | 35 | 36 | run() 37 | -------------------------------------------------------------------------------- /examples/mand5c.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | zoom = 1.0 14 | 15 | 16 | def mandelbrot(c): 17 | z = 0 18 | n = 0 19 | while abs(z) <= 2 and n < MAX_ITER: 20 | z = z * z + c 21 | n += 1 22 | return n 23 | 24 | 25 | def draw2d(): 26 | for x in range(0, WIDTH): 27 | for y in range(0, HEIGHT): 28 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH) * zoom, 29 | (IM_START + (y / HEIGHT) * IM_HEIGHT) * zoom) 30 | m = mandelbrot(c) 31 | hue = int(255 * m / MAX_ITER) 32 | saturation = 255 33 | value = 255 if m < MAX_ITER else 0 34 | color = screen.color_from_hsv(hue, saturation, value) 35 | screen.draw_pixel(x, y, color) 36 | 37 | 38 | def update(): 39 | global zoom, IM_START, RE_START 40 | if keyboard.space: 41 | zoom *= 1.2 42 | elif keyboard.enter: 43 | zoom *= 0.8 44 | elif keyboard.up: 45 | IM_START -= 0.2 46 | elif keyboard.down: 47 | IM_START += 0.2 48 | elif keyboard.left: 49 | RE_START -= 0.2 50 | elif keyboard.right: 51 | RE_START += 0.2 52 | 53 | 54 | run() 55 | -------------------------------------------------------------------------------- /examples/mand5d.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | zoom = 1.0 14 | 15 | 16 | def mandelbrot(c): 17 | z = 0 18 | n = 0 19 | while abs(z) <= 2 and n < MAX_ITER: 20 | z = z * z + c 21 | n += 1 22 | return n 23 | 24 | 25 | def draw2d(): 26 | for x in range(0, WIDTH): 27 | for y in range(0, HEIGHT): 28 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH) * zoom, 29 | (IM_START + (y / HEIGHT) * IM_HEIGHT) * zoom) 30 | m = mandelbrot(c) 31 | hue = int(255 * m / MAX_ITER) 32 | saturation = 255 33 | value = 255 if m < MAX_ITER else 0 34 | color = screen.color_from_hsv(hue, saturation, value) 35 | screen.draw_pixel(x, y, color) 36 | 37 | 38 | def update(): 39 | global zoom, IM_START, RE_START 40 | if keyboard.space: 41 | zoom *= 1.2 42 | elif keyboard.enter: 43 | zoom *= 0.8 44 | elif keyboard.up: 45 | IM_START -= 0.2 46 | elif keyboard.down: 47 | IM_START += 0.2 48 | elif keyboard.left: 49 | RE_START -= 0.2 50 | elif keyboard.right: 51 | RE_START += 0.2 52 | 53 | 54 | run() 55 | -------------------------------------------------------------------------------- /examples/mand5e.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | zoom = 1.0 14 | 15 | 16 | def mandelbrot(c): 17 | z = 0 18 | n = 0 19 | while abs(z) <= 2 and n < MAX_ITER: 20 | z = z * z + c 21 | n += 1 22 | return n 23 | 24 | 25 | def plot_image(): 26 | for x in range(0, WIDTH): 27 | for y in range(0, HEIGHT): 28 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH) * zoom, 29 | (IM_START + (y / HEIGHT) * IM_HEIGHT) * zoom) 30 | m = mandelbrot(c) 31 | hue = int(255 * m / MAX_ITER) 32 | saturation = 255 33 | value = 255 if m < MAX_ITER else 0 34 | color = screen.color_from_hsv(hue, saturation, value) 35 | screen.image_draw_pixel(image, x, y, color) 36 | 37 | 38 | image = screen.gen_image_color(WIDTH, HEIGHT, GREEN) 39 | plot_image() 40 | 41 | 42 | def init(): 43 | global texture 44 | texture = screen.load_texture_from_image(image) 45 | screen.set_texture_filter(texture, screen.TEXTURE_FILTER_BILINEAR) 46 | 47 | 48 | def draw2d(): 49 | screen.update_texture(texture, image.data) 50 | screen.draw_texture_ex(texture, (0, 0), 0, 1, WHITE) 51 | 52 | def update(): 53 | global zoom, IM_START, RE_START 54 | if keyboard.space: 55 | zoom *= 1.2 56 | plot_image() 57 | elif keyboard.enter: 58 | zoom *= 0.8 59 | plot_image() 60 | elif keyboard.up: 61 | IM_START -= 0.2 62 | plot_image() 63 | elif keyboard.down: 64 | IM_START += 0.2 65 | plot_image() 66 | elif keyboard.left: 67 | RE_START -= 0.2 68 | plot_image() 69 | elif keyboard.right: 70 | RE_START += 0.2 71 | plot_image() 72 | 73 | run() 74 | -------------------------------------------------------------------------------- /examples/mand5f.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 1920 4 | HEIGHT = 1080 5 | SCALE = 8 6 | RE_START = -2 7 | RE_END = 1 8 | IM_START = -1 9 | IM_END = 1 10 | RE_WIDTH = (RE_END - RE_START) 11 | IM_HEIGHT = (IM_END - IM_START) 12 | MAX_ITER = 80 13 | 14 | zoom = 1.0 15 | 16 | 17 | def mandelbrot(c): 18 | z = 0 19 | n = 0 20 | while abs(z) <= 2 and n < MAX_ITER: 21 | z = z * z + c 22 | n += 1 23 | return n 24 | 25 | 26 | def plot_image(): 27 | for x in range(0, WIDTH//SCALE): 28 | for y in range(0, HEIGHT//SCALE): 29 | c = complex((RE_START + (x / (WIDTH//SCALE)) * RE_WIDTH) * zoom, 30 | (IM_START + (y / (HEIGHT//SCALE)) * IM_HEIGHT) * zoom) 31 | m = mandelbrot(c) 32 | hue = int(255 * m / MAX_ITER) 33 | saturation = 255 34 | value = 255 if m < MAX_ITER else 0 35 | color = screen.color_from_hsv(hue, saturation, value) 36 | screen.image_draw_pixel(image, x, y, color) 37 | 38 | 39 | image = screen.gen_image_color(WIDTH, HEIGHT, GREEN) 40 | plot_image() 41 | 42 | 43 | def init(): 44 | global texture 45 | texture = screen.load_texture_from_image(image) 46 | screen.set_texture_filter(texture, screen.TEXTURE_FILTER_BILINEAR) 47 | 48 | 49 | def draw2d(): 50 | screen.update_texture(texture, image.data) 51 | screen.draw_texture_ex(texture, (0,0), 0, SCALE, WHITE) 52 | 53 | 54 | def update(): 55 | global zoom, IM_START, RE_START 56 | if keyboard.space: 57 | zoom *= 1.2 58 | plot_image() 59 | elif keyboard.enter: 60 | zoom *= 0.8 61 | plot_image() 62 | elif keyboard.up: 63 | IM_START -= 0.2 64 | plot_image() 65 | elif keyboard.down: 66 | IM_START += 0.2 67 | plot_image() 68 | elif keyboard.left: 69 | RE_START -= 0.2 70 | plot_image() 71 | elif keyboard.right: 72 | RE_START += 0.2 73 | plot_image() 74 | 75 | run() 76 | -------------------------------------------------------------------------------- /examples/mand6.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | 14 | def mandelbrot(c): 15 | z = 0 16 | n = 0 17 | while abs(z) <= 2 and n < MAX_ITER: 18 | z = z * z + c 19 | n += 1 20 | return n 21 | 22 | 23 | def draw2d(): 24 | for x in range(0, WIDTH): 25 | for y in range(0, HEIGHT): 26 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH), 27 | (IM_START + (y / HEIGHT) * IM_HEIGHT)) 28 | m = mandelbrot(c) 29 | color = BLACK if m == MAX_ITER else WHITE 30 | screen.draw_pixel(x, y, color) 31 | 32 | 33 | run() 34 | -------------------------------------------------------------------------------- /examples/mand7.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | 14 | def mandelbrot(c): 15 | z = 0 16 | n = 0 17 | while abs(z) <= 2 and n < MAX_ITER: 18 | z = z * z + c 19 | n += 1 20 | return n 21 | 22 | 23 | def draw2d(): 24 | for x in range(0, WIDTH): 25 | for y in range(0, HEIGHT): 26 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH), 27 | (IM_START + (y / HEIGHT) * IM_HEIGHT)) 28 | m = mandelbrot(c) 29 | i = 255 - int(255 * m / MAX_ITER) 30 | color = (i, i, i, 255) 31 | draw_pixel(x, y, color) 32 | 33 | 34 | run() 35 | -------------------------------------------------------------------------------- /examples/mand8.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 700 4 | HEIGHT = 400 5 | RE_START = -2 6 | RE_END = 1 7 | IM_START = -1 8 | IM_END = 1 9 | RE_WIDTH = (RE_END - RE_START) 10 | IM_HEIGHT = (IM_END - IM_START) 11 | MAX_ITER = 80 12 | 13 | 14 | def mandelbrot(c): 15 | z = 0 16 | n = 0 17 | while abs(z) <= 2 and n < MAX_ITER: 18 | z = z * z + c 19 | n += 1 20 | return n 21 | 22 | 23 | def draw2d(): 24 | for x in range(0, WIDTH): 25 | for y in range(0, HEIGHT): 26 | c = complex((RE_START + (x / WIDTH) * RE_WIDTH), 27 | (IM_START + (y / HEIGHT) * IM_HEIGHT)) 28 | m = mandelbrot(c) 29 | hue = int(255 * m / MAX_ITER) 30 | saturation = 255 31 | value = 255 if m < MAX_ITER else 0 32 | color = color_from_hsv(hue, saturation, value) 33 | draw_pixel(x, y, color) 34 | 35 | 36 | run() 37 | -------------------------------------------------------------------------------- /examples/pixels.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 # What are these units? What if we change them? 4 | HEIGHT = 500 # What if we delete this line? 5 | 6 | def draw(): 7 | clear() 8 | draw_pixel(250, 250, RED) 9 | 10 | run() -------------------------------------------------------------------------------- /examples/race7_test.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | import random 3 | import math 4 | 5 | WIDTH = 600 6 | HEIGHT = 800 7 | 8 | player = Sprite("alien.png", (300, 750)) 9 | player.vx = 0 # horizontal velocity 10 | player.vy = 1 # vertical velocity 11 | 12 | lines = [] # list of tuples of horizontal lines of walls 13 | wall_gradient = -3 # steepness of wall 14 | left_wall_x = 200 # x-coordinate of wall 15 | distance = 0 # how far player has travelled 16 | time = 15 # time left until game ends 17 | playing = False # True when in game, False when on title screen 18 | best_distance = 0 # remember the highest distance scored 19 | 20 | def draw(): 21 | if playing: # we are in game 22 | for i in range(0, len(lines)): # draw the walls 23 | x, x2, color = lines[i] 24 | draw_line(0, i, int(x), i, color) 25 | draw_line(int(x + x2), i, WIDTH, i, color) 26 | player.draw() 27 | else: # we are on title screen 28 | draw_text("PRESS SPACE TO START", 150, 300, 30, GREEN) 29 | draw_text("BEST DISTANCE: "+str(int(best_distance / 10)), 30 | 170, 400, 30, GREEN) 31 | draw_text("SPEED: " + str(int(player.vy)), 32 | 0, 0, 30, GREEN) 33 | draw_text("DISTANCE: " + str(int(distance / 10)), 34 | 200, 0, 30, GREEN) 35 | draw_text("TIME: " + str(int(time)), 36 | 480, 0, 30, GREEN) 37 | 38 | 39 | def update(delta): 40 | global playing, distance, time 41 | if playing: 42 | wall_collisions() 43 | scroll_walls() 44 | generate_lines() 45 | player_input() 46 | timer(delta) 47 | elif keyboard.space: 48 | playing = True 49 | distance = 0 50 | time = 10 51 | 52 | 53 | def player_input(): 54 | if keyboard.up: 55 | player.vy += 0.1 56 | if keyboard.down: 57 | player.vy -= 0.1 58 | if player.vy < 1: 59 | player.vy = 1 60 | if keyboard.right: 61 | player.vx += 0.4 62 | if keyboard.left: 63 | player.vx -= 0.4 64 | player.x += player.vx 65 | 66 | def generate_lines(): 67 | global wall_gradient, left_wall_x 68 | gap_width = 300 + math.sin(distance / 3000) * 100 69 | while len(lines) < HEIGHT: 70 | pretty_colour = Color(255, int(min(left_wall_x, 255)), int(min(time * 5, 255)), 255) 71 | lines.insert(0, (left_wall_x, gap_width, pretty_colour)) 72 | left_wall_x += wall_gradient 73 | if left_wall_x < 0: 74 | left_wall_x = 0 75 | wall_gradient = random.random() * 2 + 0.1 76 | elif left_wall_x + gap_width > WIDTH: 77 | left_wall_x = WIDTH - gap_width 78 | wall_gradient = -random.random() * 2 - 0.1 79 | 80 | generate_lines() 81 | 82 | def scroll_walls(): 83 | global distance 84 | for i in range(0, int(player.vy)): 85 | lines.pop() 86 | distance += 1 87 | 88 | def wall_collisions(): 89 | a, b, c = lines[-1] 90 | if player.x < a: 91 | player.x += 5 92 | player.vx = player.vx * -0.5 93 | player.vy = 0 94 | if player.x + 50 > a + b: 95 | player.x -= 5 96 | player.vx = player.vx * -0.5 97 | player.vy = 0 98 | 99 | def timer(delta): 100 | global time, playing, best_distance 101 | time -= delta 102 | if time < 0: 103 | playing = False 104 | if distance > best_distance: 105 | best_distance = distance 106 | 107 | def on_mouse_move(pos): 108 | x, y = pos 109 | player.x = x 110 | player.vy = (HEIGHT - y) / 20 111 | 112 | run() -------------------------------------------------------------------------------- /examples/rl_actors.py: -------------------------------------------------------------------------------- 1 | """ 2 | Models are very similar to cubes! 3 | """ 4 | from rlzero import * 5 | 6 | DATA_DIR="data" 7 | 8 | wiz = Model('rpg_characters/Wizard') 9 | wiz.size = (20,20,20) 10 | 11 | 12 | def draw(): 13 | clear() 14 | wiz.draw() 15 | 16 | 17 | def update(): 18 | wiz.x += 1 19 | if wiz.x > 100: 20 | wiz.x = -100 21 | 22 | run() 23 | 24 | """TODO 25 | try some other 3d object build-ins 26 | try downloading some .glb files from the web 27 | try creating a .glb file using https://www.leocad.org/ or https://www.blender.org/ 28 | """ 29 | -------------------------------------------------------------------------------- /examples/rl_collisions.py: -------------------------------------------------------------------------------- 1 | """ 2 | Most of this code is copied from previous programs 3 | """ 4 | 5 | from rlzero import * 6 | 7 | cube = Cube((0, 10, 0), (10, 20, 10), 'blue') 8 | DATA_DIR="data" 9 | wiz = Model('rpg_characters/Wizard') 10 | wiz.size = (20,20,20) 11 | wiz.collision_radius = 20 12 | 13 | 14 | def draw(): 15 | clear() 16 | wiz.draw() 17 | cube.draw() 18 | 19 | def update(): 20 | if keyboard.right: 21 | wiz.x += 1 22 | elif keyboard.left: 23 | wiz.x -= 1 24 | cube.x += 1 25 | if cube.x > 100: 26 | cube.x = -100 27 | if wiz.check_collision(cube): 28 | wiz.color = RED 29 | else: 30 | wiz.color = WHITE 31 | 32 | run() 33 | 34 | """ TODO 35 | joystick input (again), vertical movement (again) 36 | make the box chase the alien 37 | print number of times hit (the score) 38 | """ 39 | -------------------------------------------------------------------------------- /examples/rl_cubes_spheres.py: -------------------------------------------------------------------------------- 1 | """ 2 | IMPORTANT: switch Mu mode to "Python 3" 3 | """ 4 | from rlzero import * 5 | 6 | WIDTH = 500 7 | HEIGHT = 500 8 | 9 | cube1 = Cube((25, 0, 0)) 10 | cube2 = Cube((-25, 0, 0)) 11 | sphere = Sphere((0, 0, 0)) 12 | 13 | cube1.color = (150, 0, 0) 14 | cube2.color = BLUE 15 | 16 | 17 | def draw(): 18 | clear() 19 | cube1.draw() 20 | cube2.draw() 21 | sphere.draw() 22 | 23 | 24 | run() 25 | 26 | """ TODO: 27 | Change the colors and positions of the cubes. 28 | Make sure you understand (x,y,z) co-ordinates 29 | (In maths this called a 'Cartesian coordinate system' 30 | and everything we do in RLZero will use it) 31 | """ 32 | -------------------------------------------------------------------------------- /examples/rl_demo.py: -------------------------------------------------------------------------------- 1 | """ 2 | Demo game 3 | """ 4 | 5 | from rlzero import * 6 | import random 7 | import time 8 | 9 | TIME = 20 10 | NUMBER_OF_BALLS = 10 11 | JUMP_POWER = 2 12 | 13 | start_time = time.time() 14 | time_left = TIME 15 | 16 | CAMERA =pyray.CAMERA_PERSPECTIVE 17 | 18 | balls = [] 19 | for i in range(0, NUMBER_OF_BALLS): 20 | ball = Sphere() 21 | ball.x = random.randint(-300, 300) 22 | ball.y = random.randint(10, 40) 23 | ball.z = random.randint(-300, 0) 24 | ball.color = 'green' 25 | balls.append(ball) 26 | 27 | score = 0 28 | 29 | DATA_DIR="data" 30 | 31 | wiz = Model('rpg_characters/Wizard') 32 | wiz.size = (10, 10, 10) 33 | wiz.collision_radius = 5 34 | 35 | wiz.yv = 0 36 | wiz.xv = 0 37 | wiz.zv = 0 38 | 39 | sound = Sound('eep') 40 | sound.volume = 0.7 41 | sound.pitch = 0.5 42 | 43 | 44 | def draw(): 45 | clear() 46 | wiz.draw() 47 | for ball in balls: 48 | ball.draw() 49 | pyray.draw_circle_3d((ball.pos.x, 0, ball.pos.z),10,(1,0,0),90,BLACK) 50 | 51 | 52 | def draw2d(): 53 | if (time_left > 0): 54 | screen.draw_text(f"Score: {score} Time: {time_left}", 0, 0, 50, VIOLET) 55 | else: 56 | screen.draw_text(f"Your Score: {score}\nOUT OF TIME", 30, 50, 50, RED) 57 | 58 | 59 | def update(delta): 60 | global score 61 | global time_left 62 | 63 | print("frame delta: ", delta) 64 | camera.target = wiz.pos 65 | 66 | time_left = int(TIME + (start_time - time.time())) 67 | if time_left <= 0: 68 | return 69 | 70 | wiz.yv -= 0.05 71 | 72 | wiz.x += wiz.xv 73 | wiz.y += wiz.yv 74 | wiz.z += wiz.zv 75 | 76 | if wiz.y <= 0: # Only control when wiz is on ground 77 | if keyboard.right: 78 | wiz.xv += 0.1 79 | elif keyboard.left: 80 | wiz.xv -= 0.1 81 | if keyboard.down: 82 | wiz.zv += 0.1 83 | elif keyboard.up: 84 | wiz.zv -= 0.1 85 | 86 | if keyboard.space: 87 | wiz.yv = JUMP_POWER 88 | 89 | if wiz.xv > 0.05: 90 | wiz.xv -= 0.05 91 | elif wiz.xv < -0.05: 92 | wiz.xv += 0.05 93 | 94 | if wiz.zv > 0.05: 95 | wiz.zv -= 0.05 96 | elif wiz.zv < -0.05: 97 | wiz.zv += 0.05 98 | 99 | wiz.y = 0 100 | 101 | for ball in balls: 102 | if wiz.check_collision(ball): 103 | balls.remove(ball) 104 | sound.play() 105 | score += 1 106 | 107 | 108 | run() 109 | 110 | """ TODO 111 | gamepad controls 112 | change jump power, number of balls 113 | second player 114 | enemy that chases player 115 | 116 | """ 117 | -------------------------------------------------------------------------------- /examples/rl_displaying_text.py: -------------------------------------------------------------------------------- 1 | """ 2 | Simple game that displays text on screen 3 | Note that text is 2d, not 3d, so it must be drawn in draw2d() function 4 | """ 5 | 6 | from rlzero import * 7 | 8 | score = 0 9 | 10 | def draw(): 11 | clear() 12 | 13 | def draw2d(): 14 | pyray.draw_text(f"Player 1 score: {score}", 0, 0, 40, VIOLET) 15 | 16 | def update(): 17 | global score 18 | if keyboard.key_pressed('space'): 19 | score += 1 20 | 21 | run() 22 | 23 | 24 | """ 25 | TODO 26 | Make the score text larger and RED colored 27 | Add score2 for player 2 that increases when P key is pressed 28 | Add score display to another program, e.g. 17 29 | """ -------------------------------------------------------------------------------- /examples/rl_joystick_input.py: -------------------------------------------------------------------------------- 1 | """ 2 | RLZero has a gamepad API that is a bit different from Pygame's 3 | """ 4 | from rlzero import * 5 | 6 | DATA_DIR="data" 7 | 8 | wiz = Model('rpg_characters/Wizard') 9 | wiz.size = (20, 20, 20) 10 | wiz.pos = (0, 10, 10) 11 | 12 | 13 | def draw(): 14 | clear() 15 | wiz.draw() 16 | 17 | 18 | def update(): 19 | if gamepad.up: 20 | print("up") 21 | if gamepad.y: 22 | print("Y") 23 | if gamepad.left_stick.x > 0.3: 24 | wiz.x = wiz.x + 1 25 | elif gamepad.left_stick.x < -0.3: 26 | wiz.x = wiz.x - 1 27 | 28 | 29 | run() 30 | 31 | """TODO 32 | make the wiz move up/down and forward/back as well as left/right 33 | """ 34 | -------------------------------------------------------------------------------- /examples/rl_keyboard_input.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | DATA_DIR="data" 3 | 4 | wiz = Model('rpg_characters/Wizard') 5 | wiz.size = (20,20,20) 6 | wiz.pos = (0, 10, 10) 7 | 8 | def draw(): 9 | clear() 10 | wiz.draw() 11 | 12 | def update(): 13 | if keyboard.right: 14 | wiz.x = wiz.x + 1 15 | elif keyboard.left: 16 | wiz.x = wiz.x - 1 17 | 18 | run() 19 | 20 | """TODO 21 | make the wiz move up and down as well as left and right 22 | use the += operator to change the wiz.x 23 | use the 'or' operator to allow WASD keys to move the wiz 24 | in addition to the cursor keys 25 | make wiz wrap around when he moves off edge of screen 26 | """ 27 | -------------------------------------------------------------------------------- /examples/rl_mouse.py: -------------------------------------------------------------------------------- 1 | """ 2 | get the mouse position and test if mouse buttons are pressed 3 | """ 4 | from rlzero import * 5 | 6 | cube = Cube((0, 10, 0), (10, 20, 10), 'blue') 7 | 8 | def draw(): 9 | clear() 10 | cube.draw() 11 | 12 | 13 | def update(): 14 | cube.pos = mouse.ground_position 15 | 16 | if mouse.left_button: 17 | print("button held down") 18 | if mouse.clicked: 19 | print("mouse click") 20 | 21 | 22 | run() 23 | 24 | """ TODO 25 | Make the cube jump up when the mouse button is clicked 26 | Make the cube change colour when the mouse button is held down 27 | """ -------------------------------------------------------------------------------- /examples/rl_mouse_collisions.py: -------------------------------------------------------------------------------- 1 | """ 2 | we can check if the mouse pointer is touching a 3d object 3 | """ 4 | from rlzero import * 5 | 6 | cube = Cube((0, 10, 0), (10, 20, 10), 'blue') 7 | 8 | def draw(): 9 | clear() 10 | cube.draw() 11 | 12 | 13 | def update(): 14 | cube.x = cube.x + 1 15 | if cube.x > 100: 16 | cube.x = -100 17 | if mouse.clicked: 18 | if mouse.check_collision(cube): 19 | print("hit") 20 | else: 21 | print("miss") 22 | 23 | run() 24 | 25 | """TODO 26 | increase player score every time he clicks on cube 27 | make cube get smaller each time he clicks on it 28 | make it move to a random place after it is clicked on, e.g. 29 | import random 30 | x = random.randint(0, 100) 31 | """ 32 | -------------------------------------------------------------------------------- /examples/rl_moving_cubes.py: -------------------------------------------------------------------------------- 1 | """ 2 | to make things move we need to add 3 | the update() function 4 | """ 5 | from rlzero import * 6 | 7 | cube = Cube((0, 10, 0), (10, 20, 10), 'blue') 8 | 9 | def draw(): 10 | clear() 11 | cube.draw() 12 | 13 | 14 | def update(): 15 | cube.x = cube.x + 1 16 | if cube.x > 100: 17 | cube.x = -100 18 | 19 | run() 20 | 21 | """TODO 22 | make box move faster 23 | make box move in different direction 24 | make two boxes with different colours 25 | """ 26 | 27 | -------------------------------------------------------------------------------- /examples/rl_sounds.py: -------------------------------------------------------------------------------- 1 | """ 2 | The 'eep' sound is built-in. Other sounds must be provided as wav files. 3 | Click the mouse to play the sound. 4 | """ 5 | from rlzero import * 6 | DATA_DIR="data" 7 | sound = Sound('eep') 8 | sound.volume = 0.7 9 | sound.pitch = 0.5 10 | 11 | def draw(): 12 | clear() 13 | 14 | def update(): 15 | if mouse.clicked: 16 | sound.play() 17 | run() 18 | """TODO 19 | Change the pitch each time the mouse is clicked. 20 | Edit program 17 so that it plays a sound when you hit the cube. 21 | """ 22 | -------------------------------------------------------------------------------- /examples/rlzero: -------------------------------------------------------------------------------- 1 | ../rlzero -------------------------------------------------------------------------------- /examples/rotate.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH = 500 4 | HEIGHT = 500 5 | 6 | alan = Sprite('alien.png') 7 | alan.pos = (400, 50) 8 | box = Rectangle(20, 20, 100, 100) 9 | 10 | def draw(): 11 | draw_rectangle_rec(box, RED) 12 | alan.draw() 13 | 14 | def update(): 15 | if keyboard.right: 16 | alan.x = alan.x + 2 17 | elif keyboard.left: 18 | alan.x = alan.x - 2 19 | if keyboard.up: 20 | alan.rotation_angle = alan.rotation_angle + 1 21 | elif keyboard.down: 22 | alan.rotation_angle = alan.rotation_angle - 1 23 | #box.x = box.x + 2 24 | if box.x > WIDTH: 25 | box.x = 0 26 | if alan.colliderect(box): 27 | print("hit") 28 | 29 | 30 | run() 31 | 32 | -------------------------------------------------------------------------------- /examples/shoot17_test.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | import random 3 | 4 | WIDTH = 600 5 | HEIGHT = 800 6 | MAX_BULLETS = 3 7 | 8 | level = 1 9 | lives = 3 10 | score = 0 11 | 12 | background = Sprite("background.png") 13 | player = Sprite("player.png", (200, 730)) 14 | enemies = [] 15 | bullets = [] 16 | bombs = [] 17 | 18 | def draw(): 19 | background.draw() 20 | player.draw() 21 | for enemy in enemies: 22 | enemy.draw() 23 | for bullet in bullets: 24 | bullet.draw() 25 | for bomb in bombs: 26 | bomb.draw() 27 | draw_gui() 28 | 29 | 30 | def update(delta): 31 | move_player() 32 | move_bullets() 33 | move_enemies() 34 | create_bombs() 35 | move_bombs() 36 | check_for_end_of_level() 37 | 38 | 39 | def move_player(): 40 | if keyboard.right: 41 | player.x = player.x + 5 42 | if keyboard.left: 43 | player.x = player.x - 5 44 | if player.x > WIDTH: 45 | player.x = WIDTH 46 | if player.x < 0: 47 | player.x = 0 48 | 49 | def move_bullets(): 50 | for bullet in bullets: 51 | bullet.y = bullet.y - 6 52 | if bullet.y < 0: 53 | bullets.remove(bullet) 54 | 55 | def create_bombs(): 56 | if random.randint(0, 100 - level * 6) == 0: 57 | enemy = random.choice(enemies) 58 | bomb = Sprite("player.png", enemy.pos) 59 | bombs.append(bomb) 60 | 61 | 62 | def move_bombs(): 63 | global lives 64 | for bomb in bombs: 65 | bomb.y = bomb.y + 10 66 | if bomb.colliderect(player): 67 | bombs.remove(bomb) 68 | lives = lives - 1 69 | if lives == 0: 70 | exit() 71 | 72 | def move_enemies(): 73 | global score 74 | for enemy in enemies: 75 | enemy.x = enemy.x + enemy.vx 76 | if enemy.x > WIDTH or enemy.x < 0: 77 | enemy.vx = -enemy.vx 78 | enemy.y += 60 79 | for bullet in bullets: 80 | if bullet.colliderect(enemy): 81 | enemies.remove(enemy) 82 | bullets.remove(bullet) 83 | score = score + 1 84 | if enemy.colliderect(player): 85 | exit() 86 | 87 | def check_for_end_of_level(): 88 | global level 89 | if len(enemies) == 0: 90 | level = level + 1 91 | create_enemies() 92 | 93 | def draw_gui(): 94 | draw_text("Level " + str(level), 0, 0, 20, RED) 95 | draw_text("Score " + str(score), 100, 0, 20, RED) 96 | draw_text("Lives " + str(lives), 200, 0, 20, RED) 97 | 98 | 99 | def create_enemies(): 100 | for x in range(0, 600, 60): 101 | for y in range(0, 200, 60): 102 | enemy = Sprite("alien.png", (x, y)) 103 | enemy.vx = level * 2 104 | enemies.append(enemy) 105 | 106 | 107 | create_enemies() 108 | 109 | def on_key_pressed(key): 110 | if key == keys.space and len(bullets) < MAX_BULLETS: 111 | bullet = Sprite("alien", pos=(player.x, player.y)) 112 | bullets.append(bullet) 113 | 114 | run() -------------------------------------------------------------------------------- /rlzero/Animation.py: -------------------------------------------------------------------------------- 1 | import pyray as pr 2 | from .common import find_file 3 | 4 | 5 | class Animation: 6 | def __init__(self, files, fps=25): 7 | self.files = files 8 | self.textures = [None] * len(files) 9 | self.frame = 0 10 | self.interval = 1.0/float(fps) 11 | self.time = 0.0 12 | 13 | def get_texture(self, i): 14 | i = i % len(self.textures)-1 15 | if self.textures[i]: 16 | return self.textures[i] 17 | else: 18 | file = find_file(self.files[i], ['.png', '.jpg', ''], ['.', 'data/images', 'images']) 19 | self.textures[i] = pr.load_texture(file) 20 | return self.textures[i] 21 | 22 | def update(self, sprite): 23 | self.time += pr.get_frame_time() 24 | if self.time >= self.interval: 25 | self.frame += 1 26 | self.time -= self.interval 27 | 28 | sprite.texture = self.get_texture(self.frame) 29 | 30 | 31 | -------------------------------------------------------------------------------- /rlzero/Gamepad.py: -------------------------------------------------------------------------------- 1 | from .util import * 2 | import pyray 3 | from raylib import ffi, rl 4 | 5 | 6 | class Gamepad: 7 | """ 8 | Handles input from gamepads 9 | """ 10 | def __init__(self, id): 11 | self.id = id 12 | 13 | def test(self): 14 | if pyray.is_gamepad_available(self.id): 15 | print("Detected gamepad", self.id, ffi.string(pyray.get_gamepad_name(self.id))) 16 | 17 | @property 18 | def up(self): 19 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_LEFT_FACE_UP) 20 | 21 | @property 22 | def down(self): 23 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_LEFT_FACE_DOWN) 24 | 25 | @property 26 | def left(self): 27 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_LEFT_FACE_LEFT) 28 | 29 | @property 30 | def right(self): 31 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_LEFT_FACE_RIGHT) 32 | 33 | @property 34 | def y(self): 35 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_RIGHT_FACE_UP) 36 | 37 | @property 38 | def a(self): 39 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_RIGHT_FACE_DOWN) 40 | 41 | @property 42 | def x(self): 43 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_RIGHT_FACE_LEFT) 44 | 45 | @property 46 | def b(self): 47 | return pyray.is_gamepad_button_down(self.id, rl.GAMEPAD_BUTTON_RIGHT_FACE_RIGHT) 48 | 49 | @property 50 | def left_stick(self): 51 | return Vector([pyray.get_gamepad_axis_movement(self.id, rl.GAMEPAD_AXIS_LEFT_X), 52 | pyray.get_gamepad_axis_movement(self.id, rl.GAMEPAD_AXIS_LEFT_Y)]) 53 | 54 | @property 55 | def right_stick(self): 56 | return Vector([pyray.get_gamepad_axis_movement(self.id, rl.GAMEPAD_AXIS_RIGHT_X), 57 | pyray.get_gamepad_axis_movement(self.id, rl.GAMEPAD_AXIS_RIGHT_Y)]) 58 | 59 | -------------------------------------------------------------------------------- /rlzero/Keyboard.py: -------------------------------------------------------------------------------- 1 | from raylib import ffi, rl 2 | 3 | 4 | def _fix_key(kname): 5 | # return is a reserved word, so alias enter to return 6 | #if kname == 'enter': 7 | # kname = 'return' 8 | kname = kname.upper() 9 | if not kname.startswith("KEY_"): 10 | kname = "KEY_" + kname 11 | return kname 12 | 13 | 14 | class Keyboard: 15 | """ 16 | Handles input from keyboard 17 | """ 18 | def __getattr__(self, kname): 19 | f = _fix_key(kname) 20 | return rl.IsKeyDown(getattr(rl, f)) 21 | 22 | 23 | 24 | def key_down(self, kname): 25 | """ 26 | Test if key is currently down 27 | """ 28 | f = _fix_key(kname) 29 | return rl.IsKeyDown(getattr(rl, f)) 30 | 31 | def key_pressed(self, kname): 32 | """ 33 | Test if key was pressed recently 34 | """ 35 | f = _fix_key(kname) 36 | return rl.IsKeyPressed(getattr(rl, f)) 37 | 38 | 39 | class Keys: 40 | def __getattr__(self, kname): 41 | k = getattr(rl, _fix_key(kname)) 42 | print(k) 43 | return k 44 | -------------------------------------------------------------------------------- /rlzero/Mouse.py: -------------------------------------------------------------------------------- 1 | import pyray 2 | from raylib import ffi, rl 3 | import rlzero.globals as Globals 4 | 5 | 6 | class Mouse: 7 | """ 8 | Handles input from mouse 9 | """ 10 | def get_position_on_ground(self, ground_level): 11 | pos = pyray.get_mouse_position() 12 | ray = pyray.get_mouse_ray(pos, Globals.camera[0]) 13 | rayhit = pyray.get_collision_ray_ground(ray, ground_level) 14 | return Vector([rayhit.position.x, rayhit.position.y, rayhit.position.z]) 15 | 16 | @property 17 | def ground_position(self): 18 | return self.get_position_on_ground(0) 19 | 20 | @property 21 | def left_button(self): 22 | return pyray.is_mouse_button_down(rl.MOUSE_LEFT_BUTTON) 23 | 24 | @property 25 | def right_button(self): 26 | return pyray.is_mouse_button_down(rl.MOUSE_RIGHT_BUTTON) 27 | 28 | @property 29 | def middle_button(self): 30 | return pyray.is_mouse_button_down(rl.MOUSE_MIDDLE_BUTTON) 31 | 32 | @property 33 | def clicked(self): 34 | return pyray.is_mouse_button_pressed(rl.MOUSE_LEFT_BUTTON) 35 | 36 | def check_collision(self, actor): 37 | if not actor.loaded: 38 | actor.load_data() 39 | pos = pyray.get_mouse_position() 40 | ray = pyray.get_mouse_ray(pos, Globals.camera[0]) 41 | return pyray.check_collision_ray_box(ray, actor.calc_bounding_box()) 42 | 43 | -------------------------------------------------------------------------------- /rlzero/Sound.py: -------------------------------------------------------------------------------- 1 | from raylib import ffi, rl 2 | import rlzero.globals as Globals 3 | import os 4 | 5 | from .common import _gen_file_paths 6 | 7 | 8 | class Sound: 9 | """ 10 | A sound effect loaded from a wav file.sssss 11 | """ 12 | 13 | def __init__(self, file, volume=1.0, pitch=1.0): 14 | self.sound = None 15 | self.file = file 16 | self.loaded = False 17 | self.volume = volume 18 | self.pitch = pitch 19 | 20 | def load_data(self): 21 | """ 22 | Loads the sound data from wav file on disk. 23 | Will be called automatically the first time the sound is played. 24 | """ 25 | self.loaded = True 26 | 27 | for file in _gen_file_paths(self.file, ['.wav', ''], ['.', 'data/sounds', 'sounds']): 28 | print("trying ",file) 29 | if os.path.isfile(file): 30 | self.sound = rl.LoadSound(file.encode('utf-8')) 31 | rl.SetSoundVolume(self.sound, self._volume) 32 | rl.SetSoundPitch(self.sound, self._pitch) 33 | return 34 | raise Exception(f"file {self.file} does not exist") 35 | 36 | 37 | 38 | 39 | def play(self): 40 | """ 41 | Play the sound using the current volume and pitch. 42 | """ 43 | if not self.loaded: 44 | self.load_data() 45 | rl.PlaySound(self.sound) 46 | 47 | @property 48 | def volume(self): 49 | """ 50 | How loud to play the sound. 0.0 is silent, 1.0 is full. 51 | """ 52 | return self._volume 53 | 54 | @volume.setter 55 | def volume(self, value): 56 | if (self.loaded): 57 | rl.SetSoundVolume(self.sound, value) 58 | self._volume = value 59 | 60 | @property 61 | def pitch(self): 62 | """ 63 | Multiply the same frequency by this float. 1.0 is default pitch. 64 | """ 65 | return self._pitch 66 | 67 | @pitch.setter 68 | def pitch(self, value): 69 | if (self.loaded): 70 | rl.SetSoundPitch(self.sound, value) 71 | self._pitch = value 72 | 73 | -------------------------------------------------------------------------------- /rlzero/Sprite.py: -------------------------------------------------------------------------------- 1 | from raylib.colors import WHITE 2 | import pyray as pr 3 | 4 | from .common import find_file 5 | from .shape import Shape 6 | 7 | class Sprite(Shape): 8 | """ 9 | 2d object 10 | """ 11 | 12 | @property 13 | def scale(self): 14 | """ 15 | Multiply the scale of the object by this float. 1.0 is normal scale. 16 | """ 17 | return self._scale 18 | 19 | @scale.setter 20 | def scale(self, value): 21 | self._scale = value 22 | 23 | @property 24 | def image_file(self): 25 | return self._image_file 26 | 27 | @image_file.setter 28 | def image_file(self, value): 29 | if self.texture: 30 | pr.unload_texture(self.texture) 31 | self._image_file = value 32 | self.texture = self.load_texture(value) 33 | self.loaded = True 34 | 35 | @property 36 | def width(self): 37 | return self.texture.width 38 | 39 | @property 40 | def height(self): 41 | return self.texture.height 42 | 43 | def __init__(self, image_file, pos=(0, 0), collision_radius=0, 44 | rotation_angle=0, scale=1.0, color=WHITE): 45 | """ 46 | 47 | :param image_file: 48 | :param position: 49 | :param collision_radius: 50 | :param rotation_angle: 51 | :param scale: 52 | :param color: 53 | """ 54 | # super().__init__(position, collision_radius, color, wires, wire_color) 55 | 56 | self.pos = pos 57 | self.color = color 58 | self.texture = None 59 | 60 | 61 | self.image_file = image_file 62 | 63 | self.scale = scale 64 | 65 | self.rotation_angle = rotation_angle 66 | self.collision_radius = collision_radius 67 | 68 | def load_data(self): 69 | self.loaded = True 70 | self.texture = self.load_texture(self.image_file) 71 | 72 | def load_texture(self, file_name): 73 | file = find_file(file_name, ['.png', '.jpg', ''], ['.', 'data/images', 'images']) 74 | return pr.load_texture(file) 75 | 76 | 77 | # FIXME should we rename to check_collide? 78 | # FIXME Rectangle doesnt have equivalent method cos its not a Python class, can we patch it? 79 | def colliderect(self, other): 80 | if not self.loaded: 81 | self.load_data() 82 | r1 = pr.Rectangle(self.x, self.y, self.texture.width*self.scale, self.texture.height*self.scale) 83 | if isinstance(other, Sprite): 84 | if not other.loaded: 85 | other.load_data() 86 | r2 = pr.Rectangle(other.x, other.y, other.texture.width*other.scale, other.texture.height*other.scale) 87 | else: # assume other is: cdata 'struct Rectangle' 88 | r2 = other 89 | return pr.check_collision_recs(r1, r2) 90 | 91 | def collidepoint(self, point): 92 | r1 = pr.Rectangle(self.x, self.y, self.texture.width*self.scale, self.texture.height*self.scale) 93 | return pr.check_collision_point_rec(point, r1) 94 | 95 | def draw(self): 96 | if not self.loaded: 97 | self.load_data() 98 | cx, cy = self.width/2, self.height/2 99 | px, py = rotate((cx, cy),(0,0),-self.rotation_angle) 100 | #print(px, py) 101 | x = self.x - px + cx 102 | y = self.y - py + cy 103 | pr.draw_texture_ex(self.texture, (x, y), self.rotation_angle, self.scale, self.color) 104 | 105 | _DEG2RAD=0.01745329251 106 | 107 | import math 108 | 109 | def rotate(point, origin, degrees): 110 | radians = degrees * _DEG2RAD 111 | x,y = point 112 | offset_x, offset_y = origin 113 | adjusted_x = (x - offset_x) 114 | adjusted_y = (y - offset_y) 115 | cos_rad = math.cos(radians) 116 | sin_rad = math.sin(radians) 117 | qx = offset_x + cos_rad * adjusted_x + sin_rad * adjusted_y 118 | qy = offset_y + -sin_rad * adjusted_x + cos_rad * adjusted_y 119 | return qx, qy -------------------------------------------------------------------------------- /rlzero/__main__.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from rlzero import * 3 | 4 | file = sys.argv[1] 5 | print(file) 6 | #file_text = "from rlzero import *\n" 7 | file_text = open(file).read() 8 | #file_text += "\nrun()\n" 9 | exec(file_text) 10 | run() -------------------------------------------------------------------------------- /rlzero/basic_lighting.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec3 fragPosition; 5 | in vec2 fragTexCoord; 6 | in vec4 fragColor; 7 | in vec3 fragNormal; 8 | 9 | // Input uniform values 10 | uniform sampler2D texture0; 11 | uniform vec4 colDiffuse; 12 | 13 | // Output fragment color 14 | out vec4 finalColor; 15 | 16 | // NOTE: Add here your custom variables 17 | 18 | #define MAX_LIGHTS 4 19 | #define LIGHT_DIRECTIONAL 0 20 | #define LIGHT_POINT 1 21 | 22 | struct MaterialProperty { 23 | vec3 color; 24 | int useSampler; 25 | sampler2D sampler; 26 | }; 27 | 28 | struct Light { 29 | int enabled; 30 | int type; 31 | vec3 position; 32 | vec3 target; 33 | vec4 color; 34 | }; 35 | 36 | // Input lighting values 37 | uniform Light lights[MAX_LIGHTS]; 38 | uniform vec4 ambient; 39 | uniform vec3 viewPos; 40 | 41 | void main() 42 | { 43 | // Texel color fetching from texture sampler 44 | vec4 texelColor = texture(texture0, fragTexCoord); 45 | vec3 lightDot = vec3(0.0); 46 | vec3 normal = normalize(fragNormal); 47 | vec3 viewD = normalize(viewPos - fragPosition); 48 | vec3 specular = vec3(0.0); 49 | 50 | // NOTE: Implement here your fragment shader code 51 | 52 | for (int i = 0; i < MAX_LIGHTS; i++) 53 | { 54 | if (lights[i].enabled == 1) 55 | { 56 | vec3 light = vec3(0.0); 57 | 58 | if (lights[i].type == LIGHT_DIRECTIONAL) 59 | { 60 | light = -normalize(lights[i].target - lights[i].position); 61 | } 62 | 63 | if (lights[i].type == LIGHT_POINT) 64 | { 65 | light = normalize(lights[i].position - fragPosition); 66 | } 67 | 68 | float NdotL = max(dot(normal, light), 0.0); 69 | lightDot += lights[i].color.rgb*NdotL; 70 | 71 | float specCo = 0.0; 72 | if (NdotL > 0.0) specCo = pow(max(0.0, dot(viewD, reflect(-(light), normal))), 16); // 16 refers to shine 73 | specular += specCo; 74 | } 75 | } 76 | 77 | finalColor = (texelColor*((colDiffuse + vec4(specular, 1.0))*vec4(lightDot, 1.0))); 78 | finalColor += texelColor*(ambient/10.0); 79 | 80 | // Gamma correction 81 | finalColor = pow(finalColor, vec4(1.0/2.2)); 82 | } 83 | -------------------------------------------------------------------------------- /rlzero/basic_lighting.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes 4 | in vec3 vertexPosition; 5 | in vec2 vertexTexCoord; 6 | in vec3 vertexNormal; 7 | in vec4 vertexColor; 8 | 9 | // Input uniform values 10 | uniform mat4 mvp; 11 | uniform mat4 matModel; 12 | 13 | // Output vertex attributes (to fragment shader) 14 | out vec3 fragPosition; 15 | out vec2 fragTexCoord; 16 | out vec4 fragColor; 17 | out vec3 fragNormal; 18 | 19 | // NOTE: Add here your custom variables 20 | 21 | void main() 22 | { 23 | // Send vertex attributes to fragment shader 24 | fragPosition = vec3(matModel*vec4(vertexPosition, 1.0f)); 25 | fragTexCoord = vertexTexCoord; 26 | fragColor = vertexColor; 27 | 28 | mat3 normalMatrix = transpose(inverse(mat3(matModel))); 29 | fragNormal = normalize(normalMatrix*vertexNormal); 30 | 31 | // Calculate final vertex position 32 | gl_Position = mvp*vec4(vertexPosition, 1.0); 33 | } 34 | -------------------------------------------------------------------------------- /rlzero/common.py: -------------------------------------------------------------------------------- 1 | import os 2 | import rlzero.globals as Globals 3 | 4 | def _gen_file_paths(name, extensions, folders): 5 | paths = [] 6 | for folder in folders: 7 | for ext in extensions: 8 | paths.append(folder + os.path.sep + name + ext) 9 | paths.append(Globals.data_dir + os.path.sep + folder + os.path.sep + name + ext) 10 | paths.append(str(Globals.PATH / folder / name) + ext) 11 | return paths 12 | 13 | def find_file(name, extensions, folders): 14 | for file in _gen_file_paths(name, extensions, folders): 15 | print("trying ",file) 16 | if os.path.isfile(file): 17 | return file 18 | raise Exception(f"file {file} does not exist") -------------------------------------------------------------------------------- /rlzero/data/images/alien.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/rlzero/data/images/alien.png -------------------------------------------------------------------------------- /rlzero/data/images/alien_hurt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/rlzero/data/images/alien_hurt.png -------------------------------------------------------------------------------- /rlzero/data/models/Wizard.glb: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/rlzero/data/models/Wizard.glb -------------------------------------------------------------------------------- /rlzero/data/sounds/eep.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/electronstudio/rlzero/b5be4555cb802daf9737cb7fd376887281fd3932/rlzero/data/sounds/eep.wav -------------------------------------------------------------------------------- /rlzero/globals.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | 3 | PATH = pathlib.Path(__file__).parent 4 | 5 | light_system = None 6 | camera = None 7 | 8 | data_dir = "" -------------------------------------------------------------------------------- /rlzero/rlights.py: -------------------------------------------------------------------------------- 1 | from raylib import * 2 | import pyray as screen 3 | from .util import * 4 | import pathlib 5 | PATH = pathlib.Path(__file__).parent 6 | 7 | LIGHT_DIRECTIONAL=0 8 | LIGHT_POINT=1 9 | 10 | class LightSystem: 11 | MAX_LIGHTS = 4 #// Max dynamic lights supported by shader 12 | 13 | def __init__(self, ambient = [ 0.2, 0.2, 0.2, 1.0 ], *ls): 14 | self.lights = [] 15 | self.lightsCount = 0 16 | self.shader = screen.load_shader(str(PATH / "basic_lighting.vs"), str(PATH / "basic_lighting.fs")) 17 | 18 | self.shader.locs[SHADER_LOC_MATRIX_MODEL] = GetShaderLocation(self.shader, b"matModel"); 19 | self.shader.locs[SHADER_LOC_VECTOR_VIEW] = GetShaderLocation(self.shader, b"viewPos"); 20 | 21 | self.ambientLoc = GetShaderLocation(self.shader, b"ambient"); 22 | v = ffi.new("struct Vector4 *", ambient) 23 | SetShaderValue(self.shader, self.ambientLoc, v, SHADER_UNIFORM_VEC4); 24 | 25 | for light in ls: 26 | self.add(light) 27 | 28 | def add(self, light): 29 | light.configure(len(self.lights), self.shader) 30 | self.lights.append(light) 31 | if len(self.lights) > self.MAX_LIGHTS: 32 | raise Exception("Too many lights") 33 | 34 | def update(self, cameraPos): 35 | SetShaderValue(self.shader, self.shader.locs[SHADER_LOC_VECTOR_VIEW], ffi.new("struct Vector3 *",cameraPos), SHADER_UNIFORM_VEC3) 36 | for light in self.lights: 37 | light.UpdateLightValues() 38 | 39 | def draw(self): 40 | for light in self.lights: 41 | if light.enabled: 42 | DrawSphereEx(light.pos, 0.2, 8, 8, light.color) 43 | 44 | 45 | class Light: 46 | @property 47 | def pos(self): 48 | return self._pos 49 | 50 | @pos.setter 51 | def pos(self, value): 52 | self._pos = Vector(value) 53 | 54 | @property 55 | def target(self): 56 | return self._target 57 | 58 | @target.setter 59 | def target(self, value): 60 | self._target = Vector(value) 61 | 62 | def __init__(self, position, target, color=WHITE, type=LIGHT_POINT): 63 | self.enabled = True 64 | self.type = type 65 | self.pos = position 66 | self.target = target 67 | self.color = color 68 | 69 | 70 | 71 | def configure(self, id, shader): 72 | self.shader = shader 73 | 74 | self.enabledName = f"lights[{id}].enabled" 75 | self.typeName = f"lights[{id}].type" 76 | self.posName = f"lights[{id}].position" 77 | self.targetName = f"lights[{id}].target" 78 | self.colorName = f"lights[{id}].color" 79 | 80 | self.enabledLoc = GetShaderLocation(shader, self.enabledName.encode('utf-8')) 81 | self.typeLoc = GetShaderLocation(shader, self.typeName.encode('utf-8')) 82 | self.posLoc = GetShaderLocation(shader, self.posName.encode('utf-8')) 83 | self.targetLoc = GetShaderLocation(shader, self.targetName.encode('utf-8')) 84 | self.colorLoc = GetShaderLocation(shader, self.colorName.encode('utf-8')) 85 | 86 | self.UpdateLightValues() 87 | 88 | 89 | 90 | def UpdateLightValues(self): 91 | SetShaderValue(self.shader, self.enabledLoc, ffi.new("int *",self.enabled), SHADER_UNIFORM_INT) 92 | SetShaderValue(self.shader, self.typeLoc, ffi.new("int *",self.type), SHADER_UNIFORM_INT) 93 | 94 | #// Send to shader light position values 95 | SetShaderValue(self.shader, self.posLoc, ffi.new("struct Vector3 *",self.pos), SHADER_UNIFORM_VEC3) 96 | 97 | #// Send to shader light target position values 98 | target =[ self.target.x, self.target.y, self.target.z ] 99 | SetShaderValue(self.shader, self.targetLoc, ffi.new("struct Vector3 *",target), SHADER_UNIFORM_VEC3) 100 | 101 | #// Send to shader light color values 102 | color = [self.color[0]/255.0, self.color[1]/255.0, self.color[2]/255.0, self.color[3]/255.0] 103 | SetShaderValue(self.shader, self.colorLoc, ffi.new("struct Vector4 *",color), SHADER_UNIFORM_VEC4) 104 | 105 | -------------------------------------------------------------------------------- /rlzero/rlzero.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /rlzero/runner.py: -------------------------------------------------------------------------------- 1 | import sys 2 | from rlzero import * 3 | 4 | def main(): 5 | file = sys.argv[1] 6 | print(file) 7 | #file_text = "from rlzero import *\n" 8 | file_text = open(file).read() 9 | #file_text += "\nrun()\n" 10 | print("\nMAIN1") 11 | exec(file_text, globals()) 12 | run(sys.modules[__name__]) 13 | 14 | -------------------------------------------------------------------------------- /rlzero/util.py: -------------------------------------------------------------------------------- 1 | from .common import find_file 2 | import pyray as pr 3 | 4 | def Texture(file): 5 | texture = pr.load_texture(find_file(file, ['.png', '.jpg', ''], ['.', 'data/images', 'images'])) 6 | return texture 7 | 8 | class Vector(list): 9 | @property 10 | def x(self): 11 | return self[0] 12 | 13 | @x.setter 14 | def x(self, value): 15 | self[0] = value 16 | 17 | @property 18 | def y(self): 19 | return self[1] 20 | 21 | @y.setter 22 | def y(self, value): 23 | self[1] = value 24 | 25 | @property 26 | def z(self): 27 | return self[2] 28 | 29 | @z.setter 30 | def z(self, value): 31 | self[2] = value 32 | 33 | @property 34 | def w(self): 35 | return self[3] 36 | 37 | @w.setter 38 | def w(self, value): 39 | self[3] = value 40 | 41 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | import pathlib 2 | from setuptools import setup 3 | 4 | # The directory containing this file 5 | HERE = pathlib.Path(__file__).parent 6 | 7 | # The text of the README file 8 | README = (HERE / "README.md").read_text() 9 | 10 | # This call to setup() does all the work 11 | setup( 12 | name="rlzero", 13 | version="0.4.2", 14 | description="Pygame Zero like API to teach 3d games programming based on Raylib", 15 | long_description=README, 16 | long_description_content_type="text/markdown", 17 | url="https://github.com/electronstudio/rlzero", 18 | author="Electron Studio", 19 | author_email="github@electronstudio.co.uk", 20 | license="LGPLv3+", 21 | classifiers=[ 22 | "License :: OSI Approved :: GNU Lesser General Public License v3 or later (LGPLv3+)", 23 | "Programming Language :: Python :: 3", 24 | "Programming Language :: Python :: 3.7", 25 | "Programming Language :: Python :: 3.8", 26 | "Programming Language :: Python :: 3.9", 27 | "Programming Language :: Python :: 3.10", 28 | ], 29 | packages=["rlzero"], 30 | include_package_data=True, 31 | # entry_points={ 32 | # 'console_scripts': [ 33 | # 'rlzrun = rlzero.runner:main' 34 | # ] 35 | # }, 36 | scripts=['bin/rlzrun'], 37 | install_requires=["raylib==4.2.1.0"] 38 | ) 39 | -------------------------------------------------------------------------------- /test.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | 3 | WIDTH=800 4 | HEIGHT=640 5 | CAMERA=CAMERA_FIRST_PERSON 6 | DATA_DIR="examples/models/resources/models/" 7 | 8 | cube = Cube((0, 10, 0), (10, 20, 10), BLUE) 9 | 10 | def draw3d(): 11 | clear() 12 | cube.draw() 13 | 14 | def update(): 15 | cube.x = cube.x + 1 16 | if cube.x > 100: 17 | cube.x = -100 18 | 19 | run() -------------------------------------------------------------------------------- /test_rlzero.py: -------------------------------------------------------------------------------- 1 | from rlzero import * 2 | from rlzero.rlights import Light 3 | 4 | WIDTH=500 5 | HEIGHT=500 6 | CAMERA=rl.CAMERA_FIRST_PERSON 7 | DATA_DIR="examples/data" 8 | 9 | 10 | sound = Sound('eep') 11 | sound.volume = 0.7 12 | sound.pitch = 0.5 13 | 14 | player = Cube((0, 10, 20), (10, 20, 10), 'green') 15 | enemy_box = Cube((-40, 10, 0), (20, 20, 20), (150,0,0)) 16 | enemy_sphere = Sphere((40, 15, 0), 15, 'gray') 17 | dragon = Model("monsters/Dragon", collision_radius=15, wires=False) 18 | dragon.z=-50 19 | dragon.x=0 20 | dragon.size.y=10 21 | dragon.size.x=10 22 | dragon.size.z=10 23 | 24 | wiz = Model("rpg_characters/Wizard", collision_radius=20, wires=False, color=GREEN) 25 | wiz.z=-100 26 | wiz.x=50 27 | wiz.y=-50 28 | wiz.size = (10,10,10) 29 | wiz.pos = (50,25,-100) 30 | 31 | 32 | #def init(): 33 | #global lights0 34 | 35 | lightSystem = getLightSystem() 36 | lights0 = Light([ 30, 30, 30 ], Vector([0,0,0])) 37 | lightSystem.add(lights0) 38 | 39 | 40 | def update(): 41 | update_player() 42 | update_wiz() 43 | update_sphere() 44 | 45 | def update_player(): 46 | if keyboard.right: 47 | player.pos.x += 2 48 | elif keyboard.left: 49 | player.pos.x -= 2 50 | elif keyboard.down: 51 | player.pos.z += 2 52 | elif keyboard.up: 53 | player.pos.z -= 2 54 | 55 | if enemy_box.check_collision(player) or enemy_sphere.check_collision(player) or dragon.check_collision(player) or wiz.check_collision(player): 56 | player.color = 'red' 57 | sound.play() 58 | else: 59 | player.color = 'green' 60 | 61 | lights0.pos = player.pos 62 | 63 | def update_sphere(): 64 | #gamepad.test() 65 | #gamepad1.test() 66 | #print(gamepad.left_stick.x) 67 | if gamepad.left_stick.x > 0.3: 68 | enemy_sphere.pos.x += 2 69 | elif gamepad.left_stick.x < -0.3: 70 | enemy_sphere.pos.x -= 2 71 | elif gamepad.left_stick.y > 0.3: 72 | enemy_sphere.pos.z += 2 73 | elif gamepad.left_stick.y < -0.3: 74 | enemy_sphere.pos.z -= 2 75 | 76 | if enemy_box.check_collision(enemy_sphere) or player.check_collision(enemy_sphere) or dragon.check_collision(enemy_sphere) or wiz.check_collision(enemy_sphere): 77 | enemy_sphere.color = 'red' 78 | else: 79 | enemy_sphere.color = 'green' 80 | 81 | 82 | def update_wiz(): 83 | if keyboard.d: 84 | wiz.pos.x += 2 85 | elif keyboard.a: 86 | wiz.pos.x -= 2 87 | elif keyboard.s: 88 | wiz.pos.z += 2 89 | elif keyboard.w: 90 | wiz.pos.z -= 2 91 | 92 | if enemy_box.check_collision(wiz) or enemy_sphere.check_collision(wiz) or dragon.check_collision(wiz) or player.check_collision(wiz): 93 | wiz.color = 'red' 94 | else: 95 | wiz.color = 'green' 96 | 97 | 98 | 99 | 100 | def draw3d(): 101 | clear('white') 102 | enemy_box.draw() 103 | enemy_sphere.draw() 104 | player.draw() 105 | dragon.draw() 106 | wiz.draw() 107 | 108 | 109 | def draw2d(): 110 | screen.draw_text("Move player with cursors to collide", 220, 40, 20, (255,0,0,255)) 111 | pr.draw_fps(20, 20) 112 | 113 | 114 | 115 | run() --------------------------------------------------------------------------------