viernes, 5 de enero de 2024

Juego pruebas

import pygame pygame.init() screen = pygame.display.set_mode((400, 400)) squareX = 50 squareY = 50 circleX = 50 circleY = 50 while True: for event in pygame.event.get(): if event.type == pygame.QUIT: pygame.quit() quit() if event.type == pygame.MOUSEBUTTONDOWN: if squareX < mouse[0] < squareX + 50 and squareY < mouse[1] < squareY + 50: circleX = squareX + 25 circleY = squareY + 25 screen.fill((255, 255, 255)) pygame.draw.rect(screen, (0, 0, 0), (squareX, squareY, 50, 50)) pygame.draw.circle(screen, (0, 0, 0), (circleX, circleY), 25) circleY -= 1 pygame.display.update() let squareX = 50; let squareY = 50; let circleX = 50; let circleY = 50; function setup() { createCanvas(400, 400); } function draw() { background(220); rect(squareX, squareY, 50, 50); circle(circleX, circleY, 25); circleY -= 1; } function mousePressed() { if (mouseX > squareX && mouseX < squareX + 50 && mouseY > squareY && mouseY < squareY + 50) { circleX = squareX + 25; circleY = squareY + 25; } }let squareX = 50;
let squareY = 50;
let circleX = 50;
let circleY = 50;

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(220);
  rect(squareX, squareY, 50, 50);
  circle(circleX, circleY, 25);
  circleY -= 1;
}

function mousePressed() {
  if (mouseX > squareX && mouseX < squareX + 50 && mouseY > squareY && mouseY < squareY + 50) {
    circleX = squareX + 25;
    circleY = squareY + 25;
  }
}

No hay comentarios:

Publicar un comentario