diff --git a/code.py b/code.py new file mode 100644 index 0000000..160c486 --- /dev/null +++ b/code.py @@ -0,0 +1,192 @@ +#!/usr/bin/env python3 + +# Created by: ???? +# Created on: ???? 2019 +# This file is the "????" game +# for CircuitPython + +import ugame +import stage +import board +import neopixel +import time +import random + +import constants + + +def blank_white_reset_scene(): + # this function is the splash scene game loop + + # do house keeping to ensure everythng is setup + + # set up the NeoPixels + pixels = neopixel.NeoPixel(board.NEOPIXEL, 5, auto_write=False) + pixels.deinit() # and turn them all off + + # reset sound to be off + sound = ugame.audio + sound.stop() + sound.mute(False) + + # an image bank for CircuitPython + image_bank_1 = stage.Bank.from_bmp16("mt_game_studio.bmp") + + # sets the background to image 0 in the bank + background = stage.Grid(image_bank_1, 160, 120) + + # create a stage for the background to show up on + # and set the frame rate to 60fps + game = stage.Stage(ugame.display, 60) + # set the layers, items show up in order + game.layers = [background] + # render the background and inital location of sprite list + # most likely you will only render background once per scene + game.render_block() + + # repeat forever, game loop + while True: + # get user input + + # update game logic + + # Wait for 1/2 seconds + time.sleep(0.5) + mt_splash_scene() + + # redraw sprite list + +def mt_splash_scene(): + # this function is the MT splash scene + + # an image bank for CircuitPython + image_bank_2 = stage.Bank.from_bmp16("mt_game_studio.bmp") + + # sets the background to image 0 in the bank + background = stage.Grid(image_bank_2, constants.SCREEN_GRID_X, constants.SCREEN_GRID_Y) + + # used this program to split the iamge into tile: https://ezgif.com/sprite-cutter/ezgif-5-818cdbcc3f66.png + background.tile(2, 2, 0) # blank white + background.tile(3, 2, 1) + background.tile(4, 2, 2) + background.tile(5, 2, 3) + background.tile(6, 2, 4) + background.tile(7, 2, 0) # blank white + + background.tile(2, 3, 0) # blank white + background.tile(3, 3, 5) + background.tile(4, 3, 6) + background.tile(5, 3, 7) + background.tile(6, 3, 8) + background.tile(7, 3, 0) # blank white + + background.tile(2, 4, 0) # blank white + background.tile(3, 4, 9) + background.tile(4, 4, 10) + background.tile(5, 4, 11) + background.tile(6, 4, 12) + background.tile(7, 4, 0) # blank white + + background.tile(2, 5, 0) # blank white + background.tile(3, 5, 0) + background.tile(4, 5, 13) + background.tile(5, 5, 14) + background.tile(6, 5, 0) + background.tile(7, 5, 0) # blank white + + text = [] + + text1 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) + text1.move(20, 10) + text1.text("MT Game Studios") + text.append(text1) + + text2 = stage.Text(width=29, height=14, font=None, palette=constants.MT_GAME_STUDIO_PALETTE, buffer=None) + text2.move(35, 110) + text2.text("PRESS START") + text.append(text2) + + # get sound ready + # follow this guide to convert your other sounds to something that will work + # https://learn.adafruit.com/microcontroller-compatible-audio-file-conversion + coin_sound = open("coin.wav", 'rb') + sound = ugame.audio + sound.stop() + sound.mute(False) + sound.play(coin_sound) + + # create a stage for the background to show up on + # and set the frame rate to 60fps + game = stage.Stage(ugame.display, 60) + # set the layers, items show up in order + game.layers = text + [background] + # render the background and inital location of sprite list + # most likely you will only render background once per scene + game.render_block() + + # repeat forever, game loop + while True: + # get user input + + # update game logic + + # Wait for 1 seconds + time.sleep(1.0) + game_splash_scene() + + # redraw sprite list + +def game_splash_scene(): + # this function is the game scene + + # repeat forever, game loop + while True: + # get user input + + # update game logic + + # redraw sprite list + pass # just a placeholder until you write the code + + +def main_menu_scene(): + # this function is the game scene + + # repeat forever, game loop + while True: + # get user input + + # update game logic + + # redraw sprite list + pass # just a placeholder until you write the code + + +def game_scene(): + # this function is the game scene + + # repeat forever, game loop + while True: + # get user input + + # update game logic + + # redraw sprite list + pass # just a placeholder until you write the code + + +def game_over_scene(final_score): + # this function is the game over scene + + # repeat forever, game loop + while True: + # get user input + + # update game logic + + # redraw sprite list + pass # just a placeholder until you write the code + + +if __name__ == "__main__": + blank_white_reset_scene() \ No newline at end of file diff --git a/coin.wav b/coin.wav new file mode 100644 index 0000000..fef4191 Binary files /dev/null and b/coin.wav differ diff --git a/constants.py b/constants.py new file mode 100644 index 0000000..4fd7011 --- /dev/null +++ b/constants.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python3 + +# Created by: Mr. Coxall +# Created on: October 2019 +# This constants file is CircuitPython Stage game + +# CircuitPython screen size is 160x128 and sprites are 16x16 +SCREEN_X = 160 +SCREEN_Y = 128 +SCREEN_GRID_X = 16 +SCREEN_GRID_Y = 8 +SPRITE_SIZE = 16 +OFF_TOP_SCREEN = -1 * SPRITE_SIZE +OFF_BOTTOM_SCREEN = SCREEN_Y + SPRITE_SIZE + +MT_GAME_STUDIO_PALETTE = (b'\xf8\x1f\x00\x00\xcey\x00\xff\xf8\x1f\xff\x19\xfc\xe0\xfd\xe0' + b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff') + +SCORE_PALETTE = (b'\xf8\x1f\x00\x00\xcey\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff' + b'\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff') + +# Using for button state +button_state = { + "button_up": "up", + "button_just_pressed": "just pressed", + "button_still_pressed": "still pressed", + "button_released": "released", +} \ No newline at end of file diff --git a/docs/.DS_Store b/docs/.DS_Store new file mode 100644 index 0000000..29fd4f2 Binary files /dev/null and b/docs/.DS_Store differ diff --git a/docs/conf.py b/docs/conf.py index e370067..c696462 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -40,8 +40,8 @@ master_doc = 'index' # General information about the project. -project = u'Computer Based Problem Solving' -copyright = u'2020, Patrick Coxall' +project = u'Space Aliens - CircuitPython Game' +copyright = u'2020, Mr. Coxall' # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -131,7 +131,7 @@ # The name of an image file (relative to this directory) to place at the top # of the sidebar. -html_logo = "images/cs-logo.png" +html_logo = "images/space_aliens.png" # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 @@ -216,8 +216,8 @@ def setup(app): # Grouping the document tree into LaTeX files. List of tuples # (source start file, target name, title, author, documentclass [howto/manual]). latex_documents = [ - ('index', 'toga.tex', u'Computer Based Problem Solving', - u'Patrick Coxall', 'manual'), + ('index', 'toga.tex', u'Space Aliens - CircuitPython Game', + u'Mr. Coxall', 'manual'), ] # The name of an image file (relative to this directory) to place at the top of @@ -246,8 +246,8 @@ def setup(app): # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). man_pages = [ - ('index', 'CBPS', u'Computer Based Problem Solving', - [u'Patrick Coxall'], 1) + ('index', 'CBPS', u'Space Aliens - CircuitPython Game', + [u'Mr. Coxall'], 1) ] # If true, show URL addresses after external links. @@ -260,8 +260,8 @@ def setup(app): # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - ('index', 'CBPS', u'Computer Based Problem Solving', - u'Patrick Coxall', 'CBPS', 'Computer Based Problem Solving Textbook.', + ('index', 'CBPS', u'Space Aliens - CircuitPython Game', + u'Mr. Coxall', 'Space Aliens', 'Space Aliens - CircuitPython Game', 'Miscellaneous'), ] diff --git a/docs/game/.DS_Store b/docs/game/.DS_Store new file mode 100644 index 0000000..dbed888 Binary files /dev/null and b/docs/game/.DS_Store differ diff --git a/docs/game/background.rst b/docs/game/background.rst new file mode 100644 index 0000000..7d934ce --- /dev/null +++ b/docs/game/background.rst @@ -0,0 +1,6 @@ +.. _background: + +Background +========== + +X \ No newline at end of file diff --git a/docs/preface/.DS_Store b/docs/game/images/.DS_Store similarity index 92% rename from docs/preface/.DS_Store rename to docs/game/images/.DS_Store index e3dc158..5008ddf 100644 Binary files a/docs/preface/.DS_Store and b/docs/game/images/.DS_Store differ diff --git a/docs/game/index.rst b/docs/game/index.rst new file mode 100644 index 0000000..e55c40f --- /dev/null +++ b/docs/game/index.rst @@ -0,0 +1,14 @@ +.. _game: + +**** +Game +**** + +X + +.. toctree:: + :maxdepth: 1 + :glob: + + Background + Space Ship diff --git a/docs/game/space_ship.rst b/docs/game/space_ship.rst new file mode 100644 index 0000000..3cae99a --- /dev/null +++ b/docs/game/space_ship.rst @@ -0,0 +1,6 @@ +.. _space_ship: + +Space Ship +========== + +X diff --git a/docs/introduction/.DS_Store b/docs/ide/.DS_Store similarity index 83% rename from docs/introduction/.DS_Store rename to docs/ide/.DS_Store index 2c22069..a0afc32 100644 Binary files a/docs/introduction/.DS_Store and b/docs/ide/.DS_Store differ diff --git a/docs/ide/chrome_text_ide.png b/docs/ide/chrome_text_ide.png new file mode 100644 index 0000000..ac1352c Binary files /dev/null and b/docs/ide/chrome_text_ide.png differ diff --git a/docs/ide/circuitpython_mu-front-page.png b/docs/ide/circuitpython_mu-front-page.png new file mode 100644 index 0000000..2f66002 Binary files /dev/null and b/docs/ide/circuitpython_mu-front-page.png differ diff --git a/docs/ide/hello_world.png b/docs/ide/hello_world.png new file mode 100644 index 0000000..dc56a23 Binary files /dev/null and b/docs/ide/hello_world.png differ diff --git a/docs/ide/index.rst b/docs/ide/index.rst new file mode 100644 index 0000000..db085f5 --- /dev/null +++ b/docs/ide/index.rst @@ -0,0 +1,72 @@ + +Your IDE +======== + +One of the great things about CircuitPython hardware is that it just automatically shows up as a USB drive when you attach it to your computer. This means that you can access and save your code using any text editor. This is particularly helpful in schools, where computers are likely to be locked down so students can not load anything. Also students might be using Chromebooks, where only "authorized" Chrome extensions can be loaded. + +If you are working on a Chromebook, the easiest way to start coding is to just use the built in `Text app `_. As soon as you open or save a file with a :file:`*.py` extension, it will know it is Python code and automatically start syntax highlighting. + +.. figure:: ./chrome_text_ide.png + :width: 480 px + :align: center + :alt: Chromebook Text Editor + + Chromebook Text app + +If you are using a non-Chromebook computer, your best beat for an IDE is `Mu `_. You can get it for Windows, Mac, Raspberry Pi and Linux. It works seamlessly with CircuitPython and the serial console will give you much needed debugging information. You can download Mu `here `_. + +.. figure:: ./circuitpython_mu-front-page.png + :width: 480 px + :alt: Mu Editor + :align: center + + Mu IDE + +Since with CircuitPython devices you are just writing Python files to a USB drive, you are more than welcome to use any IDE that you are familiar using. + +Hello, World! +------------- + +Yes, you know that first program you should always run when starting a new coding adventure, just to ensure everything is running correctly! Once you have access to your IDE and you have CircuitPython loaded, you should make sure everything is working before you move on. To do this we will do the traditional "Hello, World!" program. By default CircuitPython looks for a file called :file:`code.py` in the root directory of the PyBadge to start up. You will place the following code in the :file:`code.py` file: + +.. code-block:: python + :linenos: + + print("Hello, World!") + +As soon as you save the file onto the PyBadge, the screen should flash and you should see something like: + +.. figure:: ./hello_world.png + :width: 480 px + :alt: Hello, World! + :align: center + + Hello, World! program on PyBadge + +Although this code does work just as is, it is always nice to ensure we are following proper coding conventions, including style and comments. Here is a better version of Hello, World! You will notice that I have a call to a :py:func:`main()` function. This is common in Python code but not normally seen in CircuitPython. I am including it because by breaking the code into different functions to match different scenes, eventually will be really helpful. + + +.. literalinclude:: ./example.py + :language: py + :lines: 10-20 + +.. code-block:: python + :linenos: + + #!/usr/bin/env python3 + + # Created by : Mr. Coxall + # Created on : January 2020 + # This program prints out Hello, World! onto the PyBadge + + + def main(): + # this function prints out Hello, World! onto the PyBadge + print("Hello, World!") + + + if __name__ == "__main__": + main() + + +Congratulations, we are ready to start. diff --git a/docs/image_bank/.DS_Store b/docs/image_bank/.DS_Store new file mode 100644 index 0000000..edf0b00 Binary files /dev/null and b/docs/image_bank/.DS_Store differ diff --git a/docs/image_bank/ball.bmp b/docs/image_bank/ball.bmp new file mode 100644 index 0000000..67de048 Binary files /dev/null and b/docs/image_bank/ball.bmp differ diff --git a/docs/image_bank/boom.wav b/docs/image_bank/boom.wav new file mode 100644 index 0000000..87b2536 Binary files /dev/null and b/docs/image_bank/boom.wav differ diff --git a/docs/image_bank/index.rst b/docs/image_bank/index.rst new file mode 100644 index 0000000..e3b6c63 --- /dev/null +++ b/docs/image_bank/index.rst @@ -0,0 +1,26 @@ + +Image Banks +=========== + +Before we can start coding a video game, we need to have the artwork and other assets. The stage library from CircuitPython we will be using is designed to import an "image bank". These image banks are 16 sprites staked on top of each other, each with a resolution of 16x16 pixels. This means the resulting image bank is 16x256 pixels in size. Also the image bank **must** be saved as a 16-color BMP file, with a pallet of 16 colors. To get a sprite image to show up on the screen, we will load an image bank into memory, select the image from the bank we want to use and then tell CircuitPython where we would like it placed on the screen. + +.. figure:: https://raw.githubusercontent.com/MotherTeresaHS/ICS3U-2019-Group0/master/space_aliens.bmp + :height: 256 px + :align: center + :alt: Image Bank for Space Aliens + + Image Bank for Space Aliens + +For sound, the stage library can play back :file:`*.wav` files in PCM 16-bit Mono Wave files at 22KHz sample rate. Adafruit has a great learning guide on how to save your sound files to the correct format `here `_. + +If you do not want to get into creating your own assets, other people have already made assets available to use. All the assets for this guide can be found in the GitHub repo here: + +- `space aliens image bank `_ +- `coin sound `_ +- `pew sound `_ +- `boom sound `_ +- `crash sound `_ + +Please download the assets and place them on the PyBadge, in the root directory. Your previoud "Hello, World!" program should restart and run again each time you load a new file onto the PyBadge, hopefully with no errors once more. + +Assets from other people can be found `here `_. diff --git a/docs/image_bank/jumper.bmp b/docs/image_bank/jumper.bmp new file mode 100644 index 0000000..67ffb17 Binary files /dev/null and b/docs/image_bank/jumper.bmp differ diff --git a/docs/image_bank/pew.wav b/docs/image_bank/pew.wav new file mode 100644 index 0000000..289e9cc Binary files /dev/null and b/docs/image_bank/pew.wav differ diff --git a/docs/image_bank/street_chicken.wav b/docs/image_bank/street_chicken.wav new file mode 100644 index 0000000..55d4eb0 Binary files /dev/null and b/docs/image_bank/street_chicken.wav differ diff --git a/docs/image_bank/tiles.bmp b/docs/image_bank/tiles.bmp new file mode 100644 index 0000000..edf9e35 Binary files /dev/null and b/docs/image_bank/tiles.bmp differ diff --git a/docs/image_bank/walls.bmp b/docs/image_bank/walls.bmp new file mode 100644 index 0000000..e3a08cb Binary files /dev/null and b/docs/image_bank/walls.bmp differ diff --git a/docs/image_bank/wild_eep.wav b/docs/image_bank/wild_eep.wav new file mode 100644 index 0000000..869c88c Binary files /dev/null and b/docs/image_bank/wild_eep.wav differ diff --git a/docs/images/.DS_Store b/docs/images/.DS_Store index b1e7713..be221fc 100644 Binary files a/docs/images/.DS_Store and b/docs/images/.DS_Store differ diff --git a/docs/images/3898-00.jpg b/docs/images/3898-00.jpg new file mode 100644 index 0000000..028133e Binary files /dev/null and b/docs/images/3898-00.jpg differ diff --git a/docs/images/3923-04.jpg b/docs/images/3923-04.jpg new file mode 100644 index 0000000..06489de Binary files /dev/null and b/docs/images/3923-04.jpg differ diff --git a/docs/images/4148-00.jpg b/docs/images/4148-00.jpg new file mode 100644 index 0000000..5514fe7 Binary files /dev/null and b/docs/images/4148-00.jpg differ diff --git a/docs/images/4200-01.jpg b/docs/images/4200-01.jpg new file mode 100644 index 0000000..1b4ff6c Binary files /dev/null and b/docs/images/4200-01.jpg differ diff --git a/docs/images/ComputerBasedProblemSolving.png b/docs/images/ComputerBasedProblemSolving.png deleted file mode 100644 index 6ee0a72..0000000 Binary files a/docs/images/ComputerBasedProblemSolving.png and /dev/null differ diff --git a/docs/images/cartoons/function.png b/docs/images/cartoons/function.png deleted file mode 100644 index 6be0317..0000000 Binary files a/docs/images/cartoons/function.png and /dev/null differ diff --git a/docs/images/cartoons/geeks_love_to_save_the_best_for_the_very_end.png b/docs/images/cartoons/geeks_love_to_save_the_best_for_the_very_end.png deleted file mode 100644 index cc9bbe8..0000000 Binary files a/docs/images/cartoons/geeks_love_to_save_the_best_for_the_very_end.png and /dev/null differ diff --git a/docs/images/cartoons/only_the_code_tells_the_truth.png b/docs/images/cartoons/only_the_code_tells_the_truth.png deleted file mode 100644 index 5e4ec67..0000000 Binary files a/docs/images/cartoons/only_the_code_tells_the_truth.png and /dev/null differ diff --git a/docs/images/cartoons/the_art_of_bug_fixing.png b/docs/images/cartoons/the_art_of_bug_fixing.png deleted file mode 100644 index 1d4a827..0000000 Binary files a/docs/images/cartoons/the_art_of_bug_fixing.png and /dev/null differ diff --git a/docs/images/cartoons/the_art_of_programming_1.png b/docs/images/cartoons/the_art_of_programming_1.png deleted file mode 100644 index 9b02b56..0000000 Binary files a/docs/images/cartoons/the_art_of_programming_1.png and /dev/null differ diff --git a/docs/images/cartoons/the_art_of_programming_2.png b/docs/images/cartoons/the_art_of_programming_2.png deleted file mode 100644 index ed37223..0000000 Binary files a/docs/images/cartoons/the_art_of_programming_2.png and /dev/null differ diff --git a/docs/images/cs-logo.png b/docs/images/cs-logo.png deleted file mode 100644 index 9dbc736..0000000 Binary files a/docs/images/cs-logo.png and /dev/null differ diff --git a/docs/images/cs-logo_transparent.png b/docs/images/cs-logo_transparent.png deleted file mode 100644 index 7699a24..0000000 Binary files a/docs/images/cs-logo_transparent.png and /dev/null differ diff --git a/docs/images/printed_case.jpg b/docs/images/printed_case.jpg new file mode 100644 index 0000000..6c348ae Binary files /dev/null and b/docs/images/printed_case.jpg differ diff --git a/docs/images/printed_case.png b/docs/images/printed_case.png new file mode 100644 index 0000000..2afa72d Binary files /dev/null and b/docs/images/printed_case.png differ diff --git a/docs/images/space_aliens.mov b/docs/images/space_aliens.mov new file mode 100644 index 0000000..616fd83 Binary files /dev/null and b/docs/images/space_aliens.mov differ diff --git a/docs/images/space_aliens.png b/docs/images/space_aliens.png new file mode 100644 index 0000000..c8b2cf9 Binary files /dev/null and b/docs/images/space_aliens.png differ diff --git a/docs/images/toga.png b/docs/images/toga.png deleted file mode 100644 index 3524138..0000000 Binary files a/docs/images/toga.png and /dev/null differ diff --git a/docs/index.rst b/docs/index.rst index e152bec..50faca8 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,43 +1,144 @@ + +Home +==== + .. raw:: html - + .. image:: ./images/printed_case.jpg + :width: 320 px + :height: 240 px + :alt: USB Cable + :align: left -============================== -Computer Based Problem Solving -============================== + .. container:: rightside -.. image:: /images/ComputerBasedProblemSolving.png - :alt: Computer Based Problem Solving - :align: center + `3D Printed Case `_ -The goal of this book is to take students from the point of never having done any formal programming and lead them first through a structured method of problem solving (Input-Process-Output and Top-Down design), then into basic Structured Programming and then into the early basics of Object Oriented Programming (or OOP). If this book is used to teach a high school course in computer programming, there are likely many other learning outcomes that students are required to do that are not presented in this book. The focus of this book is strictly on solving problems with computer programming. + I did not create this case. I `altered Adafruit's design `_. One of the screw posts was hitting the built in speaker and the case was not closing properly. I also added a piece of plastic over the display ribbon cable, to keep it better protected. You will need 4 x 3M screws to hold the case together. .. toctree:: - :maxdepth: 2 - :hidden: - :titlesonly: + :maxdepth: 2 + :hidden: + :titlesonly: - preface/index - introduction/index \ No newline at end of file + self + install/index + ide/index + image_bank/index + game/index + menu/index diff --git a/docs/preface/resources/.DS_Store b/docs/install/.DS_Store similarity index 92% rename from docs/preface/resources/.DS_Store rename to docs/install/.DS_Store index 5ac8b8a..97e4033 100644 Binary files a/docs/preface/resources/.DS_Store and b/docs/install/.DS_Store differ diff --git a/docs/install/index.rst b/docs/install/index.rst new file mode 100644 index 0000000..f721b24 --- /dev/null +++ b/docs/install/index.rst @@ -0,0 +1,14 @@ + +Install CircuitPython +===================== + +.. figure:: ./loading_circuitpython.gif + :width: 480 px + :alt: PyBadge UF2 + :align: center + + Clearing the PyBadge and loading the CircuitPython UF2 file + +Before doing anything else, you should delete everything already on your PyBadge and install the latest version of CircuitPython onto it. This ensures you have a clean build with all the latest updates and no leftover files floating around. Adafruit has an excellent quick start guide `here `_ to step you through the process of getting the latest build of CircuitPython onto your PyBadge. Adafruit also has a more detailed comprehensive version of all the steps with complete explanations `here `_ you can use, if this is your first time loading CircuitPython onto your PyBadge. + +Just a reminder, if you are having any problems loading CircuitPython onto your PyBadge, ensure that you are using a USB cable that not only provides power, but also provides a data link. Many USB cables you buy are only for charging, not transfering data as well. Once the CircuitPython is all loaded, come on back to continue the tutorial. diff --git a/docs/install/loading_circuitpython.gif b/docs/install/loading_circuitpython.gif new file mode 100644 index 0000000..f4657cf Binary files /dev/null and b/docs/install/loading_circuitpython.gif differ diff --git a/docs/introduction/goal-of-this-book.rst b/docs/introduction/goal-of-this-book.rst deleted file mode 100644 index 67572a8..0000000 --- a/docs/introduction/goal-of-this-book.rst +++ /dev/null @@ -1,8 +0,0 @@ -.. _goal-of-this-book: - -Goal of this book -================= - -The goal of this book is to make you a “good” programmer. Despite the fact that a normal high school semester courses run for about 90 days, you will not become an expert programmer in just one semester. It has been said that it takes around `10,000 hours `_ to really become proficient at anything and programming is no different. By the end of this book you will be very much on your way and have a good foundation in the skills you will need. The important thing to remember is that the point is not to teach you a specific programming language, since programming languages come and go and change over time. This is just like real languages. - -Although it is the official language of the Catholic Church, not too many people go around on the streets and speak `Latin `_ to their friends. Many years ago, it might have been common but not today. The tools you will learn from this book are good programming techniques. These tools will be useful no matter what programming language you are using. Just like in the real world, you cannot be called a “linguist” if you only know one language. The same thing is true for a programmer; knowing more than one language is essential. The fortunate thing is that if you know how to program and know one programming language, picking up a second one is much easier. The cornerstone of being a good programmer is to be able to solve problems in a logical and systematic way and hopefully have fun in the process. \ No newline at end of file diff --git a/docs/introduction/images/programming_language_levels.png b/docs/introduction/images/programming_language_levels.png deleted file mode 100644 index e93fdaa..0000000 Binary files a/docs/introduction/images/programming_language_levels.png and /dev/null differ diff --git a/docs/introduction/what-is-programming.rst b/docs/introduction/what-is-programming.rst deleted file mode 100644 index e96d954..0000000 --- a/docs/introduction/what-is-programming.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. _what-is-programming: - -What is programming -=================== - -Before you can actually start to write programs on a computer to help you solve problems, it would be nice to know what programming really is! We all use and see computers every day and hear people say how smart computers are. Actually, computers are not very smart at all! A computer, broken down into its most basic form is nothing more than a bunch of tiny electronic switches, called `transistors `_, that can be set to either a 1 or 0 (on or off, also known as `binary `_). By getting the computer to set these tiny switches on or off in a certain pattern, you can get the computer to actually do something useful, like show a picture on the screen that you have taken. The computer does not know how to do this by itself though. - -To communicate with your friends, one way for them to understand what you mean is for you to talk to them. To keep things simple, you both usually talk in the same language. Since a computer is just a bunch of switches, it does not understand English, so you have to talk to it in a language that it does understand. Computers use a language called `machine language `_, made up of just the 1’s and 0’s mentioned above. Trying to talk in machine language is quite difficult, easy to make mistakes in and tedious. People quickly realized they needed a better way. Assemble languages were created that used very simple instructions (like DCR C ; which decreases C counter by one). This assemble language is then run through a program that converts it to machine code. Eventually people wanted an even easier to understand language. To help people talk to a computer a `high-level programming language `_ is normally used, that is then translated into machine language so that the computer can understand what to do. This high-level language comes in many different variations and is normally just called a `programming language `_ and you have probably already heard of some of them (Java, C++, Python, …). Just like there are many different languages that people speak around the world (English, French, Spanish, …), there have been many different programming languages developed to help people instruct computers in what to do. The purpose of a programming language is to make it easier for a human to tell a computer what to do, by not having to talk machine language. - -.. image:: ./images/programming_language_levels.png - :width: 500 px - :alt: programming language levels - :align: center - -A person that uses a programming language to instruct a computer what to do is called a `programmer `_. The programmer solves whatever problem they are working on, then writes the instructions that the computer is to follow in the programming language that they have chosen. Then the computer translates the instructions into machine language (the language that the computer actually understands) and the computer performs these actions. diff --git a/docs/menu/.DS_Store b/docs/menu/.DS_Store new file mode 100644 index 0000000..30678a7 Binary files /dev/null and b/docs/menu/.DS_Store differ diff --git a/docs/menu/game_over_scene.rst b/docs/menu/game_over_scene.rst new file mode 100644 index 0000000..45c16ff --- /dev/null +++ b/docs/menu/game_over_scene.rst @@ -0,0 +1,6 @@ +.. _game_over_scene: + +Game Over Scene +=============== + +T diff --git a/docs/menu/images/.DS_Store b/docs/menu/images/.DS_Store new file mode 100644 index 0000000..5008ddf Binary files /dev/null and b/docs/menu/images/.DS_Store differ diff --git a/docs/menu/index.rst b/docs/menu/index.rst new file mode 100644 index 0000000..b8d288b --- /dev/null +++ b/docs/menu/index.rst @@ -0,0 +1,15 @@ +.. _menu: + +*********** +Menu System +*********** + +X + +.. toctree:: + :maxdepth: 1 + :glob: + + Start Scene + Splash Scene + Game Over Scene diff --git a/docs/menu/splash_scene.rst b/docs/menu/splash_scene.rst new file mode 100644 index 0000000..b241c70 --- /dev/null +++ b/docs/menu/splash_scene.rst @@ -0,0 +1,6 @@ +.. _splash_scene: + +Splash Scene +============ + +T diff --git a/docs/menu/start_scene.rst b/docs/menu/start_scene.rst new file mode 100644 index 0000000..11ab1f8 --- /dev/null +++ b/docs/menu/start_scene.rst @@ -0,0 +1,6 @@ +.. _start_scene: + +Start Scene +=========== + +X diff --git a/docs/mock_gtk/setup.py_old b/docs/mock_gtk/setup.py_old deleted file mode 100644 index fd8688f..0000000 --- a/docs/mock_gtk/setup.py_old +++ /dev/null @@ -1,28 +0,0 @@ -#/usr/bin/env python -import io -import re - -from setuptools import setup, find_packages - -# This is a mock version of the GTK+ backend. It is required because RTD -# will try to `pip install toga`, which will in turn try to -# `pip install toga-gtk`. However, RTD doesn't include GTK in it's install -# image (nor should it!), so installing toga-gtk will fail. -# -# This package fulfills the pip requirement of `toga-gtk`, without -# *actually* doing anything. - - -with io.open('../../src/gtk/toga_gtk/__init__.py', encoding='utf8') as version_file: - version_match = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", version_file.read(), re.M) - if version_match: - version = version_match.group(1) - else: - raise RuntimeError("Unable to find version string.") - - -setup( - name='toga-gtk', - version=version, - description='A mock of the GTK+ backend for the Toga widget toolkit.', -) diff --git a/docs/preface/index.rst b/docs/preface/index.rst deleted file mode 100644 index 2250d29..0000000 --- a/docs/preface/index.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. _preface: -******* -Preface -******* - -.. image:: ../images/cartoons/geeks_love_to_save_the_best_for_the_very_end.png - :height: 500 px - :alt: cartoon - :align: center - -It should be remembered that the focus of this book is to teach students how to program, not to just teach them a programming language. To do this the focus is on “Problem Solving”, using a computer program as a problem solving aid. Programming languages change over time and come and go but a good foundation of programming concepts and how to solve a problem will allow anyone to get over the syntax of a new programming language. - -This book does not include any instructions on how to load, use, create GUIs or any other housekeeping of any particular language. There are many other resources that can aid both students and teachers alike for this. - -Within the text you will see words or groups of words that are hyperlinked to `Wikipedia `_. The point of linking to Wikipedia is to give additional information about a topic if the reader is unsure about the concept. Please note that I do not have control over what is placed on Wikipedia and although it seemed useful and correct when I looked at the link, these pages are changing all the time. Despite this, the information is usually correct and can be very helpful. \ No newline at end of file diff --git a/docs/introduction/index.rst b/docs/sprites/index.rst similarity index 68% rename from docs/introduction/index.rst rename to docs/sprites/index.rst index dbd6758..eddb2e9 100644 --- a/docs/introduction/index.rst +++ b/docs/sprites/index.rst @@ -1,18 +1,5 @@ -.. _introduction: -************ -Introduction -************ -.. image:: ../images/cartoons/the_art_of_programming_1.png - :height: 600 px - :alt: cartoon - :align: center +Sprites +======= Problems have been around for as long as people have been around. The process of solving a problem is not something new. Using a computer to aid in solving a problem is new. Modern electronic computers have only been around since the Second World War (1939-1945), which might seem like a long time ago to you but in the history of the human race it is a very short time. The purpose of this book is to help you learn to structure your problem solving method, so that you can consistently develop a verifiable solution that will solve a problem and in the process, use the computer to help you more easily and quickly solve that problem. - -.. toctree:: - :maxdepth: 1 - :glob: - - What is programming - Goal of this book diff --git a/docs/supported_platforms.rst b/docs/supported_platforms.rst deleted file mode 100644 index 172cb2d..0000000 --- a/docs/supported_platforms.rst +++ /dev/null @@ -1,64 +0,0 @@ -.. table:: - - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - | Component |android|cocoa| gtk |django| iOS |web|win32| - +===================================================================+=======+=====+=====+======+=====+===+=====+ - |EXPANDING_SPACER | | | | | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |SEPARATOR | | | | | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |SPACER | | | | | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |TIBERIUS_ICON | | | | | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |Command | ||yes|||yes|| | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |Image | ||yes|||yes|| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.app.App` ||yes| ||yes|||yes|||yes| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.font.Font` | ||yes|||yes|| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.app.MainWindow` ||yes| ||yes|||yes|||yes| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.window.Window` ||yes| ||yes|||yes|||yes| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.box.Box` ||yes| ||yes|||yes|||yes| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.button.Button` ||yes| ||yes|||yes|||yes| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.canvas.Canvas` | ||yes|||yes|| | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.icon.Icon` | ||yes|||yes|| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.imageview.ImageView` | ||yes|||yes|| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.label.Label` ||yes| ||yes|||yes|||yes| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.multilinetextinput.MultilineTextInput`| ||yes|||yes|| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.numberinput.NumberInput` | ||yes|||yes|| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.optioncontainer.OptionContainer` | ||yes|||yes|| | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.passwordinput.PasswordInput` | ||yes|||yes|| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.progressbar.ProgressBar` | ||yes|||yes|| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.scrollcontainer.ScrollContainer` | ||yes|||yes|| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.selection.Selection` | ||yes|||yes|| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.splitcontainer.SplitContainer` | ||yes|||yes|| | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.table.Table` | ||yes|||yes|| | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.textinput.TextInput` ||yes| ||yes|||yes|||yes| ||yes|| ||yes|| - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.tree.Tree` | ||yes|||yes|| | | | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - |:mod:`toga.interface.widgets.webview.WebView` | ||yes|||yes|||yes| ||yes|| | | - +-------------------------------------------------------------------+-------+-----+-----+------+-----+---+-----+ - -.. |yes| replace:: ✔ - diff --git a/lib/._neopixel.mpy b/lib/._neopixel.mpy new file mode 100644 index 0000000..23cf2a8 Binary files /dev/null and b/lib/._neopixel.mpy differ diff --git a/lib/neopixel.mpy b/lib/neopixel.mpy new file mode 100644 index 0000000..04b3057 Binary files /dev/null and b/lib/neopixel.mpy differ diff --git a/mt_game_studio.bmp b/mt_game_studio.bmp new file mode 100644 index 0000000..4c6d7b6 Binary files /dev/null and b/mt_game_studio.bmp differ