level_sprite_maker_25.py

Created by wperez274

Created on April 04, 2023

10.9 KB


guide=[ """
Quickly Create Levels, Sprites, etc.
 without the hassle of the mathematics.

To be used with any of my scripts with the words "level_view" or" viewer".

After EXE,
    After printer, 

Just Copy and paste, using [Up] Arrow, [Shift], Copy....and eventually Paste.


You Welcome   :-)
-------------------------------
Contact:
wperez274@gmail.com
-------------------------------

Sincerely,

    Wilson




----------------------------------------------------------
Basic Guide
=====================================
LEFT, RIGHT, UP, DOWN Arrows = Move,  ( NAVIGATION )
=========================================

FAST MOVE     (Hold [Square] ....right above the parenthesis [ ) ] key

*[Arrows] + shift = Fast Move

 ===========================================
#Important 
#############################################

*  [Backspace] = Set Shape        
    
*  [EXE] = Exit & Print Data     ( 0f Level, Sprite, etc. )
    
*  [VAR],[SQRT] = pop last piece. (UNDO LAST).
    
         
############################################# 
--------------------------------------------------------------------------
[(] ) , [)]   =   - ( width ), (width) +
[x] ) , [/]   =   - ( height ), (height) +
[+] ) , [-]   =   -( width )+, (width)+     ( Increase width & height )
==========================================================

Fast Size Increase, Decrease:   ( Hold [Shift] ) .....Near  [Down] [Arrow]

==========================================================

[Shift] + [(] ) , [)]   =   - ( width ), (width) +
[x] ) , [/]   =   - ( height ), (height) +
[+] ) , [-]   =   -( width )+, (width)+     ( Increase width & height )
---------------------------------------------------------------------
[OK] = Random Paint "Brush"
[ZERO] = Random All Colors    ( Theme Generator ) 
------------------------------------------------------------------
[ 1 ]-[ 3 ] = Random red, green, blue

[ . ] = Paint Background White , Color Brush = Black
[ x10^ ] = Paint Background Black , Color Brush = White
---------------------------------------------------------------------------
# still working on improving this one..
  
[9] = "SKETCH MODE"
[Pi] = Clear

--------------------------
"""

]



#LEVEL & SPRITE CREATOR
#BY: WILSON
from math import *
from random import *
from random import randint as RAND 
from kandinsky import *
from kandinsky import fill_rect as F

from ion import keydown as KEYP

from kandinsky import draw_string as STR 
from ion import *
from time import *

M=255


MAPX=0
MAPY=0

sketch_mode=False



bg=(M,)*3

pixels_captured=0

SW=322
SH=222

faston=True

BLACK=(0,)*3
WHITE=(M,)*3
GRAY=(180,)*3

RED=(M,0,0)
GREEN=(0,M,0)
BLUE=(0,0,M)

CYAN=(0,M,M)
YELLOW=(M,M,100)
MAGENTA=(M,0,M)



GRAY=(155,)*3
RED=(155,0,0)
GREEN=(0,155,0)
BLUE=(0,0,155)



penup=False
pendown=True




px=40
py=100



pc=(0,0,255)


pw=50
ph=10

sprite=[]


###########################
#
# TO EDIT A LEVEL,
#
# PASTE DATA BELOW HERE!!
#
############################
#    level to edit

edited_bg= (242, 187, 75) 
edited_level= [
[MAPX+28, MAPY+105, 294, 117, (49, 14, 65)],
[MAPX+199, MAPY+52, 123, 7, (82, 92, 26)], [82, 79, 79, 7, (62, 208, 36)],
[MAPX+145, MAPY+148, 22, 42, (0, M, M)], [224, 148, 24, 42, (46, 230, 247)],
[MAPX+75, MAPY+144, 27, 43, (224, 90, 148)], [207, 59, 115, 44, (35, 6, 95)],
[MAPX+1, MAPY+46, 50, 20, (0, 0, 0)], [97, 40, 50, 20, (0, 0, 0,)]

]


edited_level_on=False


#
#
##########################





n=[px,py,pw,ph,pc]



edited_n=[]

grillon=False



TESTMODE=False

def TEST():
  
  for i in sprite:
    i[0]-=1
    F(i[0]+i[2]+1,i[1],1,i[3],bg)
    refresh_level()
    
    if i[0]<-100:
      i[0]=322
    
  
  




def draw_grill():
  global pw,ph,SW,SH

  for i in range(0,SW,pw):
    for j in range(0,SH,ph):

      F(i,0,1,SH,GREEN)
      F(0,0,1,SW,GREEN)


def print_data():
  global pw,ph,pixels_captured


  STR("W:"+str(pw)+",H:"+str(ph),40,1,BLACK,bg)

  STR("[P]:"+str(len(sprite)),140,1,CYAN,BLACK)
  F(60,20,SW,2,BLACK)


#********************
#///important!/////
#dont remove
#///////////////////


def draw_edited_level():
  global edited_level,edited_bg,SW,SH
  


  for i in edited_level:
    fill_rect(*i)





def refresh_level():
  global sprite,bg,SW,SH
  
  F(0,0,SW,SH,bg)

  for i in sprite:
    fill_rect(*i)
  




 
sleep(0.5)

cursx=150
cursy=0

#main function



sprite_history=[]




EXIT=False



while not KEYP(KEY_EXE) and not EXIT:
 

  if KEYP(KEY_LOG):
    print_data()

 

  F(px,py,pw,ph,pc)


#**************************
#  navigate
#**************************

  if KEYP(KEY_LEFT):
    px-=3
    
  if KEYP(KEY_RIGHT):

    px+=3

  if KEYP(KEY_UP):

    py-=3

  if KEYP(KEY_DOWN):
    
    py+=3
  

#**************************



  if KEYP(KEY_BACKSPACE):
    sleep(0.2)
    sprite.append(n)
    STR("[P]:"+str(len(sprite)),1,1,CYAN,BLACK)
          
#****[ pen : up,down,erase
    



#dont remove this
  n=[px,py,pw,ph,pc]

# colors
  if KEYP(KEY_EE):
    sleep(0.2)
    pc=WHITE
    bg=BLACK
    refresh_level()  
    

  
#***********************
#***********************

  if KEYP(KEY_ONE):
    sleep(0.2)
    pc=(M,RAND(0,M),RAND(0,M))
    F(px,py,pw,ph,pc)



  if KEYP(KEY_TWO):
    sleep(0.2)

    pc=(RAND(0,M),M,RAND(0,M))
    F(px,py,pw,ph,pc)




  if KEYP(KEY_THREE):
    sleep(0.2)

    pc=(RAND(0,M),RAND(0,M),M)
    F(px,py,pw,ph,pc)


  if KEYP(KEY_FOUR):
    sleep(0.2)
    pw=100
    ph=100
    refresh_level()
    
    

  if KEYP(KEY_SIX):
    sleep(0.2)

    pc=(RAND(0,M),M,M)
    F(px,py,pw,ph,pc)



  if KEYP(KEY_SEVEN):
    sleep(0.2)
  
    pc=choice([
    (RAND(0,100),RAND(0,100),RAND(0,100))
    ])
    

    
  if KEYP(KEY_EIGHT):
    sleep(0.2)

    pc=CYAN
    F(px,py,pw,ph,pc)

#/////////////////////////
#grill on
  if KEYP(KEY_NINE):
    sleep(0.2)

    draw_grill()

    refresh_level()
    draw_grill()
    F(px,py,pw,ph,pc)
    
    bg=WHITE
    pc=BLACK
    refresh_level()
    sketch_mode=True
    
    

    
  if keydown(KEY_PI):
    sketch_mode=False
    bg=WHITE
    pc=BLACK
    
    refresh_level()
    
    


  if KEYP(KEY_ANS):
    sleep(0.2)
    cursx=20
    cursy=120
    
    F(0,0,SW,SH,BLACK)
    

    while not KEYP(KEY_OK):



      STR("Press [OK] ",20,0)


      if len(sprite)>=0:
        STR(str(sprite),cursx,cursy,GREEN,BLACK)

      if KEYP(KEY_LEFT):
        F(200,1,122,20,WHITE)

        if len(sprite)<10:
          cursx-=2
        if len(sprite)>=10:
          cursx-=5

      if KEYP(KEY_RIGHT):
        F(200,1,122,20,WHITE)

        if len(sprite)<10:
          cursx+=2
        if len(sprite)>=10:
          cursx+=5



        
      if cursx>310:
        cursx=310
        
      if cursx<-len(sprite)*322:
        cursx=-len(sprite)*322


        
        
      STR("X,Y: "+str(cursx)+","+str(cursy),200,1,CYAN,BLACK)
          
        
      


    refresh_level()
    F(px,py,pw,ph,pc)




  if KEYP(KEY_LEFTPARENTHESIS):    
    pw-=2
    F(px,py,pw,ph,pc)
    
    if keydown(KEY_SHIFT):
      pw-=6
      if sketch_mode==False:
        refresh_level()
      
        
  
  if KEYP(KEY_RIGHTPARENTHESIS):
    pw+=2
    F(px,py,pw,ph,pc)
    if keydown(KEY_SHIFT):
      pw+=6
      if sketch_mode==False:
        refresh_level()



  if KEYP(KEY_MULTIPLICATION):
    ph-=2
    F(px,py,pw,ph,pc)
    if keydown(KEY_SHIFT):
      ph-=6
      if sketch_mode==False:
        refresh_level()

    

  if KEYP(KEY_DIVISION):
    ph+=2

    if keydown(KEY_SHIFT):
      ph+=6
      if sketch_mode==False:
        refresh_level()




  if KEYP(KEY_PLUS):
    pw-=2
    ph-=2
    F(px,py,pw,ph,pc)

    if keydown(KEY_SHIFT):
      pw-=6
      ph-=6
      
      
      if sketch_mode==False:
        refresh_level()



  if KEYP(KEY_MINUS):
    F(px,py,pw,ph,pc)
    pw+=2
    ph+=2
    
    if keydown(KEY_SHIFT):
      pw+=6
      ph+=6
      if sketch_mode==False:
        refresh_level()
    




  if pw<2:
    pw=2
    

  if ph<2:
    ph=2
    

  


  if KEYP(KEY_OK):
    sleep(0.2)
    pc=choice([
    RED,GREEN,BLUE,
    YELLOW,CYAN,GRAY,
    BLACK,WHITE
    ])


  if pixels_captured<0:
    pixels_captured=0
  

  if KEYP(KEY_OK):

    pc=(RAND(0,M),RAND(0,M),RAND(0,M))


  if KEYP(KEY_DOT):
    bg=WHITE
    pc=BLACK
    refresh_level()
    
    

  if KEYP(KEY_LEFT) or KEYP(KEY_RIGHT) or KEYP(KEY_UP) or KEYP(KEY_DOWN):
    if grillon==False:    
      refresh_level()


    
  if KEYP(KEY_ZERO):
    sleep(0.2)
    if len(sprite)>0:
      for i in sprite:
        i[-1]=(RAND(0,M),RAND(0,M),RAND(0,M))
      
            
      
    
    bg=(RAND(0,M),RAND(0,M),RAND(0,M))
    pc=(RAND(0,M),RAND(0,M),RAND(0,M))
    refresh_level()


    


  if KEYP(KEY_NINE):
      sleep(0.2)
      bg=WHITE
      pc=BLACK
      pw=4
      ph=4
      
      
      
      refresh_level()
      pendown=True
      grillon=True
 
      
      





    
  if KEYP(KEY_EXP):
    sleep(0.2)
    edited_level_on=True
    draw_edited_level()


  if KEYP(KEY_SINE):
      sleep(0.2)
      STR("EDIT MODE",190,1,WHITE,WHITE)
      edited_level_on=False
      refresh_level()
      




  if edited_level_on:
      STR("EDIT MODE",190,1,BLACK,CYAN)
      draw_edited_level()

    


  if py<0:
    py=0



  if py>300:
    py=190


  





  if px<0:
    px=0
    
  if px+pw>322:
    px=322-pw
  if py<0:
    py=0
  if py+ph>222:
    py=222-ph

  
    
  if KEYP(KEY_LEFT):
    F(200,2,70,18,WHITE)
    if keydown(KEY_SQUARE):
      px-=8
      if sketch_mode==False:
        refresh_level()


    
    
    
  if KEYP(KEY_RIGHT):
    F(200,2,70,18,WHITE)
    if keydown(KEY_SQUARE):
      px+=8
      if sketch_mode==False:
        refresh_level()



  if KEYP(KEY_UP):
    F(200,2,70,18,WHITE)
    if keydown(KEY_SQUARE):
      py-=8
      if sketch_mode==False:
        refresh_level()



  if KEYP(KEY_DOWN):
    F(200,2,70,18,WHITE)
    if keydown(KEY_SQUARE):
      py+=8
      if sketch_mode==False:
        refresh_level()


#important
# pop last piece

  if KEYP(KEY_VAR):
    if len(sprite)>0:
      sleep(0.2)
      del sprite[-1]
      refresh_level()
    
    





  if KEYP(KEY_LOG):
    TESTMODE==True
    
    
  if TESTMODE:
    TEST()
    
    
  if KEYP(KEY_TANGENT) or KEYP(KEY_BACKSPACE):

    STR("[P]:"+str(len(sprite)),1,1,CYAN,BLACK)




  if KEYP(KEY_LEFTPARENTHESIS):
    F(px+pw-1,py,1,ph,CYAN)
    F(px+pw+1,py,2,ph,bg)

  if KEYP(KEY_MULTIPLICATION):
    F(px,py+ph-1,pw,1,CYAN)
    F(px,py+ph+1,pw,2,bg)

  if KEYP(KEY_PLUS):
    F(px,py+ph-1,pw,1,CYAN)
    F(px,py+ph+1,pw,2,bg)

    F(px+pw-1,py,1,ph,CYAN)
    F(px+pw+1,py,2,ph,bg)



  if KEYP(KEY_POWER):
    sleep(0.2)
    px=150
    py=100
    pw=3
    ph=3
    bg=BLACK
    pc=WHITE
    
    
    

  if KEYP(KEY_VAR):
    if len(sprite)==0:
      pw=10
      ph=10
      refresh_level()
      sleep(0.1)


      


  if KEYP(KEY_TOOLBOX):
    sleep(0.2)
    pw+=pw
    ph+=ph

    
    

  if pw>SW:
    pw=SW
    

  if ph>SH:
    ph=SH


    
    




    
        
#///END//////  

STR("press [OK]",100,100)  
  

sleep(1)




print("\n") 
name=input("name: ") 



if len(name)<1: 
  name="level" 
    
  

  
print("bg = ",bg) 


print(name,"=",sprite)

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.