agario_de_wish.py

Created by gengisclan

Created on August 22, 2023

2.32 KB

Bienvenue dans un agar.io solo (mois bien que le vrai)


# Modules
from math import *
from kandinsky import *
from ion import *
from time import *
from random import *

# Fonctions
def Mouvement(joueur):
  if keydown(KEY_DOWN):
    joueur[1]+=1
    if joueur[1]+joueur[2]>222:joueur[1]=222-joueur[2]
  if keydown(KEY_UP):
    joueur[1]-=1
    if joueur[1]<0:joueur[1]=0
  if keydown(KEY_RIGHT):
    joueur[0]+=1
    if joueur[0]+joueur[2]>320:joueur[0]=320-joueur[2]
  if keydown(KEY_LEFT):
    joueur[0]-=1
    if joueur[0]<0:joueur[0]=0
      
def Refresh(joueur,entitees,nvent,fps):
  fill_rect(0,0,320,240,(0,)*3)
  fill_rect(joueur[0],joueur[1],joueur[2],joueur[3],joueur[4])
  for i in entitees.keys():fill_rect(entitees[i][0],entitees[i][1],2,2,(0,255,0))
  sleep(fps)  

def Couleur(joueur,verif,vitesse):
  if verif%vitesse==0:joueur[4]=(randint(0,255),randint(0,255),randint(0,255))
  while joueur[4]==(0,)*3 or joueur[4]==(0,255,0):joueur[4]=(randint(0,255),randint(0,255),randint(0,255))  

def Spawn(entitees,nvent,verif):
  if verif%(vitesse/2)==0 and len(entitees)<=50:
    nvent=[randint(0,320),randint(0,240)]
    fill_rect(nvent[0],nvent[1],2,2,(0,255,0))
    entitees["ent "+str(verif)]=nvent

def Colision(joueur,entitees,kill):
  for i in entitees.keys():
    if entitees[i][0]+2>joueur[0] and entitees[i][1]+2<joueur[1]+joueur[2]:
      if entitees[i][1]+2>joueur[1] and entitees[i][0]+2<joueur[0]+joueur[2]:
        del entitees[i]
        joueur[2]+=1
        joueur[3]+=1
        kill+=1
  return kill

def Logo():
  fill_rect(0,0,320,240,(0,)*3)
  fill_rect(100,80,120,60,(255,)*3)
  fill_rect(101,81,118,58,(0,)*3)
  draw_string("Cree par",120,90,(255,)*3,(0,)*3)
  draw_string("Gengisclan",110,110,(255,)*3,(0,)*3)
  sleep(2)
   
# Variables
joueur=[10,10,10,10,(randint(0,255),randint(0,255),randint(0,255))]
verif=0
vitesse=50
entitees={}
nvent=0
fps=1/100
kill=0
debut=monotonic()

Logo()
# Programme
while 1:
  Refresh(joueur,entitees,nvent,fps) # Actualise l'ecran
  Couleur(joueur,verif,vitesse) # Change le joueur de couleur
  Spawn(entitees,nvent,verif) # Genere de nouvelles entitees
  verif+=1
  Mouvement(joueur) # Gere le mouvement du joueur
  kill=Colision(joueur,entitees,kill) # Verifie si le joueur entre en
# contact avec une entitee 
  if joueur[2]>=320:
    fill_rect(0,0,320,240,(255,255,255))
    print("score: ",round(kill+(monotonic()-debut),4))
    break

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.