egor_0.py

Created by wperez274

Created on February 01, 2023

9.76 KB

Collision detection. Energy Capsules Bar. ( energy amount ) Flying bullets. Moving platforms. Floating jump (Hold Down Arrow for a few seconds to float for longer.


# WRITTEN BY: WILSON
from math import *
from random import *
from kandinsky import *
from ion import *
from time import *
from random import randint as R
from random import choice as CH
from kandinsky import fill_rect as F
from kandinsky import draw_string as STR
from ion import keydown as GK
"""
sleep(0.2)
bg=(0,0,100)
F(0,0,322,222,"black")
F(0,0,322,5,"red")
F(0,40,322,2,"red")

while not GK(KEY_OK):
  STR("NINJA RAIDEN",110,12,"cyan","black")
  STR("[BACKSPACE]/[UP] = JUMP/FLOAT",20,90,"orange","black")
  STR("[DOWN] = Bend Down/Descend",20,140,"yellow","black")
  STR("(  PRESS [OK] to PLAY )",10,200,"white","black")
#*************************
#///   MAP[x,y] point  /////
#*************************
#Top-Left of your screen
sleep(0.6)

"""



MAP_X=0
MAP_Y=0

bg=(R(0,155),R(0,55),R(0,255))
g_clock=0
g_dir=0
game=True
gravity=True
p_on_plat=True

gx=MAP_X+R(0,200)
gy=MAP_Y+R(100,200)
gw=R(90,200)
gh=R(10,20)
gc="brown"
#grass
grass_x=gx
grass_y=gy
grass_w=gw
grass_h=3
grass_c=(0,R(50,255),0)

level=1

fuel=3

super_mode=False
super_mode_time=0
super_mode_duration=2


p_attacks=False
p_face_left=False
p_face_right=True

px=gx+30
py=MAP_Y+10
pw=12
ph=18
pc=(25,37,100)
pe=35
psc=0

cl_0_x=gx+R(400,500)
cl_0_y=R(0,30)
cl_0_w=R(30,50)
cl_0_h=R(8,20)
cl_0_c="white"

plat_x=[
MAP_X+R(0,75),
MAP_X+R(100,150),
MAP_X+R(200,275)
]

plat_0_y=R(40,200)
plat_0_w=R(50,100)
plat_0_h=12
plat_0_c="red"

plat_1_y=R(40,200)
plat_1_w=R(50,100)
plat_1_h=12
plat_1_c="white"

plat_2_y=R(40,200)
plat_2_w=R(50,100)
plat_2_h=12
plat_2_c="blue"

crit_0_x=R(gx,gx+gw-14)
crit_0_w=14
crit_0_h=8
crit_0_y=grass_y-3-crit_0_h
crit_0_c="black"

crit_1_x=R(gx,gx+gw-14)
crit_1_w=14
crit_1_h=8
crit_1_y=grass_y-3-crit_1_h
crit_1_c="green"
#bullets
enemy_x=[
MAP_X+R(320,580),
MAP_X+R(800,1080),
]
#male
e_0_y=R(20,180)
e_0_w=45
e_0_h=25
e_0_c=CH([
"black","brown","blue","red",
(R(0,100),R(0,100),R(0,100))
])

#female
e_1_y=R(20,180)
e_1_w=40
e_1_h=22
e_1_c=CH([
"pink","magenta","purple","cyan",
(R(120,150),R(0,150),R(0,150))
])


F(MAP_X,MAP_Y,322,222,bg)

while pe>0:
#DATA PRINT  
  for i in range(200,round((200+pe/2)),9):
    F(i,2,7,7,"white")

  for i in range(200,round((200+pe/2)),9):
    F(i,2,7,7,"red")
    F(i,3,2,2,"white")
    F(i,3,2,2,"white")

  F(200+round(pe)+2,2,4,10,bg)

#CLOUD 0
  F(cl_0_x,cl_0_y,cl_0_w,cl_0_h,cl_0_c)
  F(cl_0_x+cl_0_w+1,cl_0_y,2,cl_0_h,bg)
  F(cl_0_x,cl_0_y,2,cl_0_h,"cyan")
  F(cl_0_x+cl_0_w-2,cl_0_y,2,cl_0_h,"cyan")
  F(cl_0_x,cl_0_y,cl_0_w,2,"cyan")
  F(cl_0_x,cl_0_y+cl_0_h-2,cl_0_w,2,"cyan")
#Player
  F(px,py,pw,ph,pc)
#Player face
  F(px+2,py+3,pw-4,4,"white")
#Player eyes
  F(px+3,py+4,2,5,"black")
  F(px+7,py+4,2,5,"black")
#Player outline
  F(px,py,1,ph,"black")
  F(px+pw-2,py,1,ph,"black")
  F(px,py,pw,1,"black")
  F(px,py+ph-1,pw,1,"black")
#ground  
  F(gx,gy,gw,gh,gc)
#enemy bullets
  F(enemy_x[0],e_0_y,e_0_w,e_0_h,e_0_c)
  F(enemy_x[1],e_1_y,e_1_w,e_1_h,e_1_c)
#eyes
  F(enemy_x[0]+5,e_0_y+5,10,8,"blue")
  F(enemy_x[1]+5,e_1_y+5,10,8,"green")
#white of eye  
  F(enemy_x[0]+5+10-5,e_0_y+6,5,6,"white")
#white of eye  
  F(enemy_x[1]+5+10-5,e_1_y+6,5,6,"white")
  F(enemy_x[0]+5,e_0_y+5,2,8,"black")
  F(enemy_x[0]+5+10-2,e_0_y+5,2,8,"black")
  F(enemy_x[0]+5,e_0_y+5,10,2,"black")
  F(enemy_x[0]+5,e_0_y+5+8-2,10,2,"black")
  F(enemy_x[1]+5,e_1_y+5,2,8,"black")
  F(enemy_x[1]+5+10-2,e_1_y+5,2,8,"black")
  F(enemy_x[1]+5,e_1_y+5,10,2,"black")
  F(enemy_x[1]+5,e_1_y+5+8-2,10,2,"black")
#erase
  F(enemy_x[0]+e_0_w+1,e_0_y,2,e_0_h,bg)
  F(enemy_x[1]+e_1_w+1,e_1_y,2,e_1_h,bg)
#outline
  F(enemy_x[0],e_0_y,1,e_0_h,"black")
  F(enemy_x[0]+e_0_w-1,e_0_y,1,e_0_h,"black")
  F(enemy_x[0],e_0_y,e_0_w,1,"black")
  F(enemy_x[0],e_0_y+e_0_h-1,e_0_w,1,"black")
  F(enemy_x[1],e_1_y,1,e_1_h,"black")
  F(enemy_x[1]+e_1_w-1,e_1_y,1,e_1_h,"black")
  F(enemy_x[1],e_1_y,e_1_w,1,"black")
  F(enemy_x[1],e_1_y+e_1_h-1,e_1_w,1,"black")
  F(MAP_X+plat_x[0],plat_0_y,2,plat_0_h,"black")
  F(MAP_X+plat_x[0]+plat_0_w-2,plat_0_y,2,plat_0_h,"black")
  F(MAP_X+plat_x[0],plat_0_y,plat_0_w,2,"black")
  F(MAP_X+plat_x[0],plat_0_y+plat_0_h-2,plat_0_w,2,"black")
  F(MAP_X+plat_x[1],plat_1_y,2,plat_1_h,"black")
  F(MAP_X+plat_x[1]+plat_1_w-2,plat_1_y,2,plat_1_h,"black")
  F(MAP_X+plat_x[1],plat_1_y,plat_1_w,2,"black")
  F(MAP_X+plat_x[1],plat_1_y+plat_1_h-2,plat_1_w,2,"black")
  F(MAP_X+plat_x[2],plat_2_y,2,plat_2_h,"black")
  F(MAP_X+plat_x[2]+plat_2_w-2,plat_2_y,2,plat_2_h,"black")
  F(MAP_X+plat_x[2],plat_2_y,plat_2_w,2,"black")
  F(MAP_X+plat_x[2],plat_2_y+plat_2_h-2,plat_2_w,2,"black")
#enemies reach left screen
#randomize positions or locations
  if enemy_x[0]+e_0_w<=-10:
    enemy_x[0]=R(350,450)
    e_0_y=py
    pe+=0.3
    psc+=R(11,33)
  if enemy_x[1]+e_1_w<=-10:
    enemy_x[1]=R(450,650)
    e_1_y=py+CH([-20,20])
    pe+=0.3
    psc+=R(10,20)
  enemy_x[0]-=CH([1,2])
  enemy_x[1]-=CH([1,2])
#***************************
#gravity affects player jump
  if gravity:
    py+=1
    F(px,py-1,pw,1,bg)
  
  if px+pw>=gx and px<=gx+gw and py+ph>=gy and py+ph<=gy+2:
    py=gy-ph
    p_on_plat=True
    fuel=3
#GK J alias name for keydown()    
  if GK(KEY_LEFT):
    px-=2
    F(px+pw+1,py,pw,2,bg)
  if GK(KEY_BACKSPACE) and fuel>0 or GK(KEY_UP) and fuel>0:
    py-=2
    fuel-=0.04
    F(px,py+ph+1,pw,2,bg)
  if GK(KEY_LEFT):
    px-=1
    F(px+pw+1,py,3,ph,bg)
  if GK(KEY_RIGHT):
    px+=2
    F(px-2,py,2,ph,bg)
  
  if px+pw>=plat_x[0] and px<=plat_x[0]+plat_0_w and py+ph>=plat_0_y and py+ph<=plat_0_y+2:
    py=plat_0_y-ph
    p_on_platform=True
    fuel=3
      
  if px+pw>=plat_x[1] and px<=plat_x[1]+plat_1_w and py+ph>=plat_1_y and py+ph<=plat_1_y+2:
    py=plat_1_y-ph
    p_on_platform=True
    fuel=3

  if px+pw>=plat_x[2] and px<=plat_x[2]+plat_2_w and py+ph>=plat_2_y and py+ph<=plat_2_y+2:
    py=plat_2_y-ph
    p_on_platform=True
    fuel=3

  if px+pw>=enemy_x[0] and px<=enemy_x[0]+e_0_w and py+ph>=e_0_y and py+ph<=e_0_y+e_0_h:
    F(px,py,pw,ph,"red")
    F(px+pw+1,py,3,ph,bg)
    pe-=0.5
    px-=1

  if px+pw>=enemy_x[1] and px<=enemy_x[1]+e_1_w and py+ph>=e_1_y and py+ph<=e_1_y+e_1_h:
    F(px,py,pw,ph,"red")
    F(px+pw+1,py,3,ph,bg)
    pe-=0.5
    px-=1

  F(MAP_X+plat_x[0],plat_0_y,plat_0_w,plat_0_h,plat_0_c)
  F(MAP_X+plat_x[1],plat_1_y,plat_1_w,plat_1_h,plat_1_c)
  F(MAP_X+plat_x[2],plat_2_y,plat_2_w,plat_2_h,plat_2_c)


  if keydown(KEY_DOWN):
    F(px,py-10,pw,10,bg)
    ph=10
    py+=1
  else:
    ph=18


  if px+pw<0:
    px=322
  if px>=322:
    px=0
#*****************************
#*****************************
#player teleports to a new game!

  if py<=-50:
    from egor_2 import *

#*****************************
#*****************************
    
#///the key to reaching the stars
#...or a new world...    
  if py+ph>=230:
    py=230-ph
    fuel=7




  if GK(KEY_OK):
    while not GK(KEY_VAR):
      draw_string("< PAUSED >",110,0)
      draw_string("[ Press [VAR] to resume ]",30,20)  
    draw_string("< PAUSED >",110,0,bg,bg)
    draw_string("[ Press [VAR] to resume ]",30,20,bg,bg)  
        
  pe+=0.01
  
#critters on ground
  F(MAP_X+crit_0_x,crit_0_y,crit_0_w,crit_0_h,crit_0_c)  
  F(MAP_X+crit_1_x,crit_1_y,crit_1_w,crit_1_h,crit_1_c)  


#outline
  F(crit_0_x,crit_0_y,1,crit_0_h,"red")
  F(crit_0_x+crit_0_w-1,crit_0_y,1,crit_0_h,"red")
  F(crit_0_x,crit_0_y,crit_0_w,1,"red")
  F(crit_0_x,crit_0_y+crit_0_h-1,crit_0_w,1,"red")

  F(crit_1_x,crit_1_y,1,crit_1_h,"green")
  F(crit_1_x+crit_1_w-1,crit_1_y,1,crit_1_h,"green")
  F(crit_1_x,crit_1_y,crit_1_w,1,"green")
  F(crit_1_x,crit_1_y+crit_1_h-1,crit_1_w,1,"green")

#movement
  F(MAP_X+crit_0_x-2,crit_0_y,2,crit_0_h,bg)  
  F(MAP_X+crit_0_x+crit_0_w+1,crit_0_y,2,crit_0_h,bg)  
  F(MAP_X+crit_1_x-2,crit_1_y,2,crit_1_h,bg)  
  F(MAP_X+crit_1_x+crit_1_w+1,crit_1_y,2,crit_1_h,bg)  

  if px+pw>=crit_0_x and px<=crit_0_x+crit_0_w and py+ph>=crit_0_y and py+ph<=crit_0_y+crit_0_h:
    F(px,py,pw,ph,"red")
    F(px+pw+1,py,3,ph,bg)
    pe-=0.1
    px-=1

  if px+pw>=crit_1_x and px<=crit_1_x+crit_1_w and py+ph>=crit_1_y and py+ph<=crit_1_y+crit_1_h:
    F(px,py,pw,ph,"red")
    F(px+pw+1,py,3,ph,bg)
    pe-=0.1
    px-=1

  if e_0_y>=100 and e_0_y<=gy-5-30:
    F(enemy_x[0],gy-7,e_0_w,2,"black")
    F(enemy_x[0]+e_0_w,gy-7,2,2,bg)


  if e_1_y>=100 and e_1_y<=gy-5-30:
    F(enemy_x[1],gy-7,e_1_w,2,"black")
    F(enemy_x[1]+e_0_w,gy-7,2,2,bg)

#--------------------------
#length(sword) = 33              = 33
#width(sword)  = 3
#--------------------------
#*****[ REMEMBER ]*******
# the pixel arguments in the
# fill_rect(x,y,w,h,c)
# the "w" is the ==== [horizontal] ====
# measurement.
# the "h" is the || [vertical] || 
# measurement
  
  if keydown(KEY_TOOLBOX):
    p_attacks=True
    F(px+pw+1,py+9,20,3,"black")
    F(px+pw+5,py+7,2,8,(24,65,25))
    sleep(0.01)
    F(px+pw+1,py+9,20,3,bg)
    F(px+pw+5,py+7,2,8,bg)

  cl_0_x-=CH([0,1])
  
  if cl_0_x+cl_0_w<0-R(50,100):
    cl_0_x=R(600,900)
    cl_0_y=R(0,40)
    cl_0_w=R(20,50)
    cl_0_h=R(8,20)


#ground goes up and down randomly.
  g_clock+=0.02
  if g_clock>R(3,7):
    g_clock=0
    g_dir=CH([0,3,4,0])
  if g_dir==3:
    gy-=1
    F(gx,gy+gh+1,gw,1,bg)
  
  if g_dir==4:
    F(gx,gy-1,gw,1,bg)
    gy+=1
    F(crit_0_x,crit_0_y-1,crit_0_w,1,bg)
    F(crit_1_x,crit_1_y-1,crit_1_w,1,bg)
    

  if gy>=220:
    gy=220
  if gy<=55:
    gy=55
    
  if crit_0_x<0:
    crit_0_x=322
    crit_0_y=R(20,200)



  if crit_1_x>322:
    crit_1_x=0
    crit_1_y=R(20,200)
  crit_0_x-=CH([0,1])
  crit_1_x+=CH([0,1])

  if GK(KEY_DOWN):
    super_mode_time+=0.1
  
  if super_mode_time>3:
    super_mode=True
    
  if super_mode:
    F(px,py,2,ph,"magenta")
    F(px+pw-2,py,2,ph,"magenta")
    F(px,py,pw,2,"magenta")
    F(px,py+ph-2,pw,2,"magenta")
    super_mode_duration-=0.005
    fuel=4
    
  if super_mode_duration<=0:
    super_mode_duration=2
    super_mode=False
    super_mode_time=0
    
    
F(0,0,322,222,"black")
STR("GAME OVER",100,100,"orange","black")
sleep(1)
STR("SCORE: "+str(psc),100,140,"white","black")

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.