Coder Social home page Coder Social logo

snappy's Introduction

snappy

Python version of UCB's Snap (see http://snap.berkeley.edu)

Snappy is in an extremely early state at this point. I've only been using Python for a couple months, and I've only been working on Snappy for a few days, so if you happen to find this, please don't think it is even alpha software. You have been so warned.

This tool is being developed as an supplementary environment for students that are using Snap! to learn coding. It provides a basic framework of classes and methods that allow the student to create Snap-like projects, but using Python syntax instead of dragging/dropping graphical blocks.

Snappy is built on top of the PyGame framework (http://pygame.org). It does all of the heavy-lifting of actually drawing the sprites. Snappy simply provides a structured framework to set the state of the sprites that are then drawn by PyGame.

Eventually, I will package this up and check it into a PyPI server, but for now, just clone the repo and add a new Python file for your project. Really, all you need is Snappy.py. The other files in this repo are just informational.

Set Up

Requirements:

I'd also suggest an actual Python IDE for beginners (which face it, is who will actually be using Snappy), but it's not required.

Caveats

Snappy is currently pre-alpha state. There are probably lots of bugs, and it hasn't been stress-tested at all. In particular, there are several bits of Snap functionality that are not yet implemented (see Blocks).
In addition, the functionality to start, pause and stop the program is not implemented, yet. When the project is run, it begins processing mouse and keyboard events, sending the appropriate messages to the sprites. You cannot pause a project, and the only way to stop it is to close the window.

Creating a project

Create a new python file in the snappy directory and include this minimal code:

from Snappy import TheProject
 
TheProject.Run()

If you run the above code, all you will get is a blank stage that does nothing. Pretty boring.

To add a little more fun, you can add a "sprite" to the project to actually get something drawn.

from Snappy import TheProject
from Snappy import Sprite
 
TheProject.AddSprite(Sprite())
TheProject.Run()

Running this code will get you a lonely little turtle sitting in the middle of the screen (I decided to make the default sprite actually look like a turtle instead of an arrowhead called a turtle).

To make things even more interesting, you will need to add a sprite that has actual code within it. This is done by creating a new class that inherits from the Sprite class, then adding code to respond to events that will make the sprite perform.

from Snappy import TheProject
from Snappy import Sprite
 
class ScaredTurtle(Sprite):
    def WhenIAmClicked(self):
        self.Move(50)
 
TheProject.AddSprite(ScaredTurtle())
TheProject.Run()

See Blocks for information about each block type

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.