I am... surprised that it actually did it. I wonder who's code it copied
Here's the prompt I gave it:
Come up with a concept for a very simple game that can be programmed in Love2D. Another AI will be tasked of creating this game, so you must create a list of every task that must be completed for the AI to follow.
I then took part of the response, then gave it back to a different conversation (not all of the response was really relevant, though it would be funny to tell chatgpt to "Test the game thoroughly to identify and fix any bugs"
Code: Select all
-- main.lua
function love.load()
-- Set up the game window
love.window.setTitle("Space Dodge")
screenWidth, screenHeight = 800, 600
love.window.setMode(screenWidth, screenHeight)
-- Initialize game variables
player = { x = screenWidth / 2, y = screenHeight - 50, speed = 300, width = 50, height = 50 }
asteroids = {}
score = 0
gameover = false
end
function love.update(dt)
if not gameover then
-- Move the player
if love.keyboard.isDown("left") and player.x > 0 then
player.x = player.x - player.speed * dt
elseif love.keyboard.isDown("right") and player.x < screenWidth - player.width then
player.x = player.x + player.speed * dt
end
-- Update asteroids
updateAsteroids(dt)
-- Check for collisions
checkCollisions()
-- Update score
score = score + 1
end
end
function love.draw()
-- Draw player
love.graphics.rectangle("fill", player.x, player.y, player.width, player.height)
-- Draw asteroids
for _, asteroid in ipairs(asteroids) do
love.graphics.circle("fill", asteroid.x, asteroid.y, asteroid.radius)
end
-- Draw score
love.graphics.print("Score: " .. score, 10, 10)
-- Draw game over screen
if gameover then
love.graphics.print("Game Over", screenWidth / 2 - 50, screenHeight / 2 - 30)
love.graphics.print("Score: " .. score, screenWidth / 2 - 40, screenHeight / 2)
love.graphics.print("Press R to Try Again", screenWidth / 2 - 70, screenHeight / 2 + 30)
end
end
function spawnAsteroid()
local asteroid = {
x = math.random(screenWidth),
y = -20,
radius = math.random(20, 40),
speed = math.random(50, 150)
}
table.insert(asteroids, asteroid)
end
function updateAsteroids(dt)
for i, asteroid in ipairs(asteroids) do
asteroid.y = asteroid.y + asteroid.speed * dt
-- Remove asteroids that are out of the screen
if asteroid.y > screenHeight then
table.remove(asteroids, i)
spawnAsteroid()
end
end
-- Spawn a new asteroid with a chance
if math.random() < 0.01 then
spawnAsteroid()
end
end
function checkCollisions()
for _, asteroid in ipairs(asteroids) do
if checkCollision(player, asteroid) then
gameover = true
end
end
end
function checkCollision(a, b)
return a.x < b.x + b.radius and
a.x + a.width > b.x and
a.y < b.y + b.radius and
a.y + a.height > b.y
end
function love.keypressed(key)
if gameover and key == "r" then
love.load() -- Reset the game
end
end
Potential follow up - completely automate the process then start bemoaning on twitter how no one considers this an artistic skill.
Edit: I tried asking it to create a game from a single prompt, and it generated a catching game instead, with the reverse premise