Juego de Asteroides con GPT-4 y Texturas de IA
De Wikiprompt, la enciclopedia libre de prompts
Juego de Asteroides con GPT-4 y Texturas de IA Un prompt para generar un juego completo de Asteroids en p5.js con texturas personalizadas, controlado por el mouse y disparo con clic izquierdo.
Contenido del PromptGuardar
🌐
let ship;
let asteroids = [];
let bullets = [];
let gameOver = false;
let win = false;
// Texture variables - replace these with your own image files
let shipImg;
let asteroidImg;
function preload() {
// Load your textures here - make sure to use your own file names
shipImg = loadImage('ship.png');
asteroidImg = loadImage('asteroid.png');
}
function setup() {
createCanvas(800, 600);
// Create the spaceship at the center
ship = {
x: width / 2,
y: height / 2,
radius: 20
};
// Create a set of asteroids
for (let i = 0; i < 8; i++) {
asteroids.push({
x: random(width),
y: random(height),
vx: random(-2, 2),
vy: random(-2, 2),
radius: random(20, 40)
});
}
}
function draw() {
background(0);
if (gameOver) {
fill(255, 0, 0);
textSize(32);
textAlign(CENTER);
text('GAME OVER - You Lost!', width / 2, height / 2);
return;
}
if (win) {
fill(0, 255, 0);
textSize(32);
textAlign(CENTER);
text('YOU WIN!', width / 2, height / 2);
return;
}
// Move spaceship with mouse
ship.x = mouseX;
ship.y = mouseY;
// Display spaceship with texture
imageMode(CENTER);
image(shipImg, ship.x, ship.y, 50, 50);
// Update and display asteroids
for (let i = asteroids.length - 1; i >= 0; i--) {
let a = asteroids[i];
a.x += a.vx;
a.y += a.vy;
// Wrap around edges
if (a.x < 0) a.x = width;
if (a.x > width) a.x = 0;
if (a.y < 0) a.y = height;
if (a.y > height) a.y = 0;
// Display asteroid with texture
image(asteroidImg, a.x, a.y, a.radius * 2, a.radius * 2);
// Check collision with ship
let d = dist(ship.x, ship.y, a.x, a.y);
if (d < ship.radius + a.radius) {
gameOver = true;
}
// Check collision with bullets
for (let j = bullets.length - 1; j >= 0; j--) {
let b = bullets[j];
let db = dist(b.x, b.y, a.x, a.y);
if (db < b.radius + a.radius) {
asteroids.splice(i, 1);
bullets.splice(j, 1);
break;
}
}
}
// Update and display bullets
for (let i = bullets.length - 1; i >= 0; i--) {
let b = bullets[i];
b.x += b.vx;
b.y += b.vy;
// Remove bullets that go off screen
if (b.x < 0 || b.x > width || b.y < 0 || b.y > height) {
bullets.splice(i, 1);
continue;
}
// Draw bullet (simple yellow line)
stroke(255, 255, 0);
strokeWeight(4);
line(b.x, b.y, b.x - b.vx * 2, b.y - b.vy * 2);
}
// Check win condition
if (asteroids.length === 0) {
win = true;
}
}
function mousePressed() {
if (mouseButton === LEFT && !gameOver && !win) {
// Shoot a bullet in the direction of the mouse from the ship position
let angle = atan2(mouseY - ship.y, mouseX - ship.x);
let speed = 5;
bullets.push({
x: ship.x,
y: ship.y,
vx: cos(angle) * speed,
vy: sin(angle) * speed,
radius: 5
});
}
}
Iniciá sesión para ver el prompt completo
Continuar con:
Al iniciar sesión, aceptás nuestros Términos de uso y Política de privacidad
Uso
Este prompt está diseñado para usarse con coding. Copiá el contenido de arriba y pegalo en tu herramienta de IA preferida.
Para mejores resultados, personalizá los marcadores (indicados con corchetes o mayúsculas) con tus requisitos específicos.
Discusión
0 comentarios