gameboy_sketch.py

Created by wperez274

Created on April 06, 2023

4.11 KB

will eventually add a couple of games..


from math import *
from random import *
from kandinsky import *
from random import randint as RAND 
from kandinsky import *
from kandinsky import fill_rect as F
from kandinsky import draw_string as STR 
from ion import *
from time import *





shape=[]



shape_width=0
shape_height=0
shape_c=(255,0,0)


n=[0,0,shape_width,shape_height,shape_c]


bg=(RAND(100,255),RAND(100,255),RAND(100,255))


gameboy_black=(39,41,41)


gameboy_body_c=(196,190,187)


gameboy_button_c=(154,34,87)



gameboygreen=(139,172,15)


gameboygreen_2=(132,208,125)



gameboy = [
#body
[19, 15, 128, 194, gameboy_body_c],

[31, 30, 102, 78, (55, 55, 55)], 
[40, 39, 86, 62, (139,172,15)], 
#arrows
[34, 135, 32, 8, gameboy_black],
[46, 123, 10, 30, gameboy_black],


[118, 126, 12, 10, gameboy_button_c],

[100, 138, 12, 10, gameboy_button_c],

[19+45, 19+160, 15, 5, (70, 70, 70)],
[19+45+15+5, 19+160, 15, 5, (70, 70, 70)]


]



panel= [

[200, 80, 110, 106, (45, 80, 144)], 
[206, 86, 95, 91, (155, 155, 155)]

]




gameboy_off=True
gameboy_on=False

x=gameboy[2][0]+30
y=gameboy[2][1]+RAND(5,25)
w=3
h=3
c=(0,54,0)

score=0
lives=3

player=[x,y,w,h,c]



F(0,0,322,222,bg)

for i in gameboy:
  F(*i)







F(gameboy[0][0]-3,gameboy[0][1],3,gameboy[0][3],(0,0,0))

F(gameboy[0][0],gameboy[0][1]-1,gameboy[0][2],1,(0,0,0))

F(gameboy[0][0],gameboy[0][1]+gameboy[0][3],gameboy[0][2],2,(0,0,0))


GAMEOVER=False

if gameboy_off:
  F(gameboy[2][0],gameboy[2][1],gameboy[2][2],gameboy[2][3],(0,95,0))


for i in panel:
  F(*i)


      
while not keydown(KEY_EXE):
  
  
  
  
  

  if gameboy_on:
    
    gameboy[2][-1]=gameboygreen

    

  if gameboy_on:
    gameboy_off=False

    if keydown(KEY_LEFT):
      sleep(0.01)
      player[0]-=1


    if keydown(KEY_RIGHT):
      sleep(0.01)
      player[0]+=1
      
    if keydown(KEY_UP):
      sleep(0.01)
      player[1]-=1

    if keydown(KEY_DOWN):
      sleep(0.01)
      player[1]+=1


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

    if player[0]<=gameboy[2][0]:
      player[0]=gameboy[2][0]


    if player[0]+player[2]>gameboy[0][2]:
      player[0]=gameboy[0][2]-player[2]

    if player[1]<=gameboy[2][1]:
      player[1]=gameboy[2][1]

    if player[1]>gameboy[2][1]+gameboy[2][3]-2:
      player[1]=gameboy[2][1]+gameboy[2][3]-2




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

    


      
    F(*player)

      
      

    

#0=False
#1=True    


  if keydown(KEY_OK):
    gameboy_off=False
    F(gameboy[2][0],gameboy[2][1],gameboy[2][2],gameboy[2][3],gameboygreen)

    sleep(0.2)
    gameboy_on+=1
  
  if gameboy_on>1:
    gameboy_on=0  
  
  
  
  if gameboy_on==0:
    F(gameboy[2][0],gameboy[2][1],gameboy[2][2],gameboy[2][3],(0,95,0))
  
  
  

  if keydown(KEY_BACKSPACE):
    sleep(0.2)
    shape=[]
    F(gameboy[2][0],gameboy[2][1],gameboy[2][2],gameboy[2][3],gameboygreen)

  
  
  draw_string("x:"+str(player[0])+" , "+str(player[1]),200,1)

  
  
  if keydown(KEY_LEFT):
    draw_string("x:"+str(player[0])+" , "+str(player[1]),200,1,bg,bg)

  if keydown(KEY_RIGHT):
    draw_string("x:"+str(player[0])+" , "+str(player[1]),200,1,bg,bg)
    
  if keydown(KEY_UP):
    draw_string("x:"+str(player[0])+" , "+str(player[1]),200,1,bg,bg)
  if keydown(KEY_DOWN):
    draw_string("x:"+str(player[0])+" , "+str(player[1]),200,1,bg,bg)
  
  
  
  
  draw_string("bg:"+str(bg),150,200)



  n=[0,0,shape_width,shape_height,shape_c]



  if keydown(KEY_TOOLBOX):
    draw_string(str(shape_width)+","+str(shape_height),200,40)
    if keydown(KEY_RIGHT):
      shape_width+=1
    
    if keydown(KEY_LEFT):
      shape_width-=1

    if keydown(KEY_UP):
      shape_height-=1
    
    if keydown(KEY_DOWN):
      shape_height+=1
    

  if keydown(KEY_SHIFT):
    draw_string(str(shape),200,100)



  if shape_width<0:
    shape_width=0
    

  if shape_height<0:
    shape_height=0



  if keydown(KEY_ONE):
    n[-1]=(255,0,0)
    


  if keydown(KEY_TWO):
    n[-1]=(0,100,0)






  draw_string(str(n[-1]),200,21)

    
  fill_rect(200,40,shape_width,shape_height,shape_c)
    
    
    
    
shape.append(n)
  
  
  
F(0,0,322,222,gameboygreen)
draw_string("Press [OK]",100,100,gameboy_black,gameboygreen)  
  



print("bg=",bg)

  
print("shape=",n)

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.