Coder Social home page Coder Social logo

bradparks / load81__pico8_like Goto Github PK

View Code? Open in Web Editor NEW

This project forked from antirez/load81

0.0 2.0 0.0 1.65 MB

SDL based Lua programming environment for kids similar to Codea

License: BSD 2-Clause "Simplified" License

Makefile 1.36% C 57.55% Shell 1.27% HTML 33.58% C++ 3.16% CSS 0.33% JavaScript 0.37% Roff 0.85% Batchfile 0.13% Lua 1.39%

load81__pico8_like's Introduction

README

Load81 is an attempt at creating a Codea-inspired environment to teach children how to write Lua programs. It features a graphical programming environment and a Commodore-64 style integrated editor so that the programmer is confined into a friendly environment with a simple editor:

Load81 Editor

The following is a screenshot of the running program (examples/asteroids.lua). The programmer can currently switch between edit and play mode pressing the ESC key.

Load81 Asteroids

Load81 is written in ANSI C and uses SDL and SDL_gfx and SDL_image, so should compile on Mac OS X and Linux without issues. It should not be hard to port it to Windows.

The coordinate system and the basic drawing functions are compatible with Codea (check http://twolivesleft.com/Codea/ for more information), but there is no support for stroke.

There is no aim at Codea compatibility, but who is familiar with Codea should feel at home with Load81 in terms of API and structure of the program.

I wrote it mainly because I and my children have fun with Codea but we don't have an iPad at home, and using a real keyboard sometimes can be less frustrating.

The name Load81 originates from the fact that in popular Commodore home computers the command LOAD "*",8,1 would load the first program on the disk starting from the file-specified memory location.

USAGE

Start Load81 with:

./load81 example.lua

To switch between program and editor mode press the ESC key.

Check the "examples" folder for small examples.

PROGRAMMING INTERFACE

Drawing functions:

  • fill(r,g,b,alpha): select the drawing color.
  • background(r,g,b): paint the whole background with the specified color.
  • rect(x,y,width,height): draw a rectangle at x,y (left-bottom corner).
  • ellipse(x,y,width,height): draw an ellipse centered at x,y.
  • line(x1,y1,x2,y2): draw a line from x1,y1 to x2,y2.
  • text(x,y,string): print the specified text at x,y using a bitmap font.
  • triangle(x1,y1,x2,y2,x3,y3): draw a triangle with the specified vertex.
  • getpixel(x,y): return the red,gree,blue value of the specified pixel.
  • sprite(file,x,y,[rotation],[antialiasing]): draw sprite at coordinates with the specified rotation (in degrees, default 0) and antialiasing (default false).

Control functions:

  • setFPS(fps): Set the frame rate. For default it's set to 30 frames per second.

KEYBOARD EVENTS

To check if a key 'a' is pressed use:

if keyboard.pressed['a'] then ...

SDL Key symbol names are used. You can easily find how a given key is called using the following Lua program:

function draw()
    for k,v in pairs(keyboard.pressed) do
        print(k)
    end
end

(You can find this program under the examples folder).

LOW LEVEL KEYBOARD EVENTS

It is also possible to trap low level SDL events accessing keyboard.state and keyboard.key fields of the keyboard table.

keyboard.state is one of:

"down" -> KEYDOWN event
"up"   -> KEYUP event
"none" -> No event

keyboard.key is set to the key pressed or released when state is different than "none".

MOUSE EVENTS

mouse.x and mouse.y gives you the current mouse coordinates. To check if a button is pressed use:

if mouse.pressed['1'] then ...

Mouse buttons are called '1', '2', '3', ... and so forth.

LICENSE

Load81 was written by Salvatore Sanfilippo and is released under the BSD two-clause license, see the COPYING file for more information.

The load81 project is dedicated to Jack Tramiel, founder of Commodore.

load81__pico8_like's People

Contributors

antirez avatar badboy avatar beanz avatar bl0ckeduser avatar dpino avatar franciscopinto avatar heliosmaster avatar nopcoder avatar rlane avatar

Watchers

 avatar  avatar

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.