M30W Programming Forum

M30W is a text-based version of Scratch

You are not logged in.

Announcement

This is the development forum for M30W (also known as Emerald, do not confuse with Emerald Programming Language).
Our Non-development forums are available here

M30W(Emerald) 0.3 is out! (Download) Requires Python 2.6 or higher.
Opal 0.3(A better command line M30W) is out! (Download) Requires Python 2.6 or higher.
M30W 0.3.6 GUI barebones (Download) Requires Python 2.6 or higher and wxPython
Diamond-2 RED2 GUI Barebones (Fancy M30W editor) s out! (Download) Requires .NET Framework 3.5 or higher, does not require Python
M30W++ GUI barebones (Java M30W) Alpha 1 is out! (Download) Requires Java.


Gershmer.net, our hosting, will close in February 2011. We have not fully decided what to do with our hosting after that, but we will tell you when we decide.

Adverts

Adverts

#1 2010-03-17 00:01:03

hidas
M30W Team
From: The 3rd dimension
Registered: 2009-11-11
Posts: 142
Website

Python M30W Development Thread

This is the official development of the main M30W (which will hopefully be in wxPython, NOT PyGame)
Gershmer has provided a version (from Magnie and The-Whiz, who are gone :() of Opal 0.1 in defs (a way to code things in Python) for us to transfer in to a 100% GUI M30W, which will either be called 0.4 or 1.0alpha.

OLD STUFF (PyGame source, etc.)













Gershmer had an opal in defs on his computer, and I've been adding lists, variables, and sprites to it. So far:

Code:

import time, pygame, sys
from pygame.locals import *
# Defs

def help():
    print "M3OW help"
    print ""
    print "Here are M3OW's commands:"
    print "print 'text' - prints text"
    print "wait # s - waits the specified # of seconds"
    print "list - lists the program"
    print "run - runs the program"
    print "make variable - makes an object that can change"
    print "make list - makes a list of items"
    print "add to list - adds and item of your choosing to a list"
    print "change variable - changes the value of a variable of your choosing"

def list():
    print "Program:"
    print ""
    for i in range(0, len(commands)):
        if commands[i] == 'print':
            print "print '" + commands2[i] + "'"
        elif commands[i] == 'wait':
            print "wait " + commands2[i] + " s"  #" cycles"
    print ""

def run():
    global movewithkeys, movewithmouse
    print "Running program:"
    print ""
    while True:
        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                sys.exit()
        for sprite in spritelist:
            screen.blit(sprite.image, sprite.location)
        for i in range(0, len(commands)):
            if commands[i] == 'print':
                print commands2[i]
            elif commands[i] == 'wait':
                time.sleep(int(commands2[i]))
            
        print ""

def exit():
    global running_opal
    print "Are you sure? Y/N"
    sureyesno = raw_input("")
    if sureyesno[0] == 'y':
        running_opal = 0  # terminate the loop in a polite way, not polite way: break

def a():
    i = 7
    to_print = ''
    while i < len(command) - 1:
        to_print = to_print + command[i]
        i = i + 1
    commands.append('print')
    commands2.append(to_print)

def b():
    i = 5
    to_wait = ''
    while i < len(command) - 2:
        to_wait = to_wait + command[i]
        i = i + 1
    commands.append('wait')
    commands2.append(to_wait)
def makevariable():
    global dictvars
    name = raw_input("What is the name of your variable? ")
    value = raw_input("And what is its value? ")
    dictvars[name] = value
def changevariable():
    global dictvars
    var_to_change = raw_input("Which variable would you like to change? ")
    if var_to_change in dictvars:
        print "The current value of that variable is:", dictvars[var_to_change]
        
        replace = raw_input("What would you like to replace it with? ")
        dictvars[var_to_change] = replace
    else:
        yesorno = raw_input("That variable does not exist. Would you like to make it? Y/N")
        if yesorno.lower() == 'y':
            makevariable()
        
def makelist():
    global dictlists
    name = raw_input("What is the name of your list? ")
    dictlists[name] = []
def addlist():
    global dictlists
    whichlist = raw_input("What list would you like to add to? ")
    if whichlist in dictlists:
        print "These are the values currently stored in the list:", dictlists[whichlist]
        
        wta = raw_input("What would you like to add to this list? ")
        dictlists[whichlist].append(wta)
    else:
        if raw_input("This list does not exist, would you like to make it? Y/N") == 'y':
            makelist()
    
def makesprite():
    global spritelist
    spritename = raw_input("What is the name of your sprite? ")
    keys = bool(raw_input("Can it move with the arrow keys? Y/NONE "))
    mouse = bool(raw_input("Can it move with the mouse? Y/NONE "))
    sprite = Sprite(spritename)
    spritelist.append(sprite)
    
#Classes
class Sprite(pygame.sprite.Sprite):
    def __init__(self, name):
        pygame.sprite.Sprite.__init__(self)
        self.image = pygame.draw.circle(screen, [255, 255, 255], [300, 250], 5, 0)
        self.name = name
#        self.movekeys = keys
#        self.movemouse = mouse
        self.location = [300, 250]
# Start Program
print "M3OW v0.1"
print "A text-based programming language"
place_holder = raw_input("Hit enter to initiate M3OW")
valid_commands = ['print', 'wait']
commands = []
commands2 = []
spritelist = []
running_opal = 1
running_program = 0
dictvars = {}
dictlists = {}
width, height = 600, 500
pygame.init()
screen = pygame.display.set_mode([width, height])
screen.fill
while running_opal == 1:
    print "Enter command:"
    command = raw_input("")
    if command[0] == valid_commands[0][0] and command[1] == valid_commands[0][1] and command[2] == valid_commands[0][2] and command[3] == valid_commands[0][3] and command[4] == valid_commands[0][4]:
        a()
    elif command[0] == valid_commands[1][0] and command[1] == valid_commands[1][1] and command[2] == valid_commands[1][2] and command[3] == valid_commands[1][3]:
        b()
    elif command == 'help':
        help()
    elif command == 'list':
        list()
    elif command == 'run':
        run()
    elif command == 'make variable':
        makevariable()
    elif command == 'change variable':
        changevariable()
    elif command == 'make list':
        makelist()
    elif command == 'add to list':
        addlist()
    elif command == 'make sprite':
        makesprite()
    elif command == 'exit':
        exit()
    else:
        print "That is not a valid command."

Last edited by Gershmer (2010-05-13 19:09:22)


Heh heh heh (Semi-evil laugh)

Offline

 

2010-03-17 00:01:03

AdBot
Advertisements

#2 2010-03-17 00:02:32

hidas
M30W Team
From: The 3rd dimension
Registered: 2009-11-11
Posts: 142
Website

Re: Python M30W Development Thread

Anything involving sprites does not work yet, but you can make variables and lists, change them, and of course, print, wait, and list.


Heh heh heh (Semi-evil laugh)

Offline

 

#3 2010-03-17 15:59:57

markyparky56
Hi...
From: Scotland
Registered: 2009-10-08
Posts: 910
Website

Re: Python M30W Development Thread

Ok... do i need anything for this to run? And why are you using PyGame? I thought we weren't using PyGame...


I am A M30Wr.
I always get the last word.

Offline

 

#4 2010-03-17 17:00:41

hidas
M30W Team
From: The 3rd dimension
Registered: 2009-11-11
Posts: 142
Website

Re: Python M30W Development Thread

Filo5's Diamond uses Pygame. And the only thing you need is pygame.


Heh heh heh (Semi-evil laugh)

Offline

 

#5 2010-03-17 18:41:13

cds56
THE TOOOTH! THE TOOOOOOOOOOOOTH!!!!!
From: Canamadiana
Registered: 2009-11-07
Posts: 423

Re: Python M30W Development Thread

Pygame site's down ATM so I'll wait till later to test it. so, anyone post a screeny?


http://www.catb.org/esr/faqs/glider.png

Offline

 

#6 2010-03-17 19:05:36

markyparky56
Hi...
From: Scotland
Registered: 2009-10-08
Posts: 910
Website

Re: Python M30W Development Thread

When we release 0.1 we'll need to have it install all the plugins needed.


I am A M30Wr.
I always get the last word.

Offline

 

#7 2010-05-13 19:02:32

Gershmer
Admin
From: Newton Centre, Massachusetts
Registered: 2009-10-08
Posts: 515
Website

Re: Python M30W Development Thread

UPDATE TO THIS: DO NOT USE PYGAME. USE THIS WXPYTHON-BUILT LAYOUT TO MAKE M30W IN


http://card.ly/images/vcard-green-small.png

Offline

 

Adverts

Board footer

Powered by FluxBB
Hosted by PunBB-Hosting