Log In  


Cart #zowwogisi-0 | 2022-12-18 | Code ▽ | Embed ▽ | No License
1

I found out that Open AI's ChatGPT understands programming, including Pico 8 LUA. I had it create something simple, a pong game. I did create the sound effects, but 99.9% of the code was created by ChatGPT. I found the best way to get it to add more code without timing out is to just request it to create code snippets for _draw() and or _update()

Code:

p1_y = 36
p2_y = 36
ball_x = 64
ball_y = 36
ball_vx = 1
ball_vy = 1
p1_score = 0
p2_score = 0
game_state = "start"

function _update()
 if game_state == "start" and (btn(4) or btn(5)) then
    game_state = "play"
    p1_score = 0
    p2_score = 0
  end

  -- move the paddles
  if btn(0) then p1_y -= 1 end
  if btn(1) then p1_y += 1 end
  if btn(2) then p2_y -= 1 end
  if btn(3) then p2_y += 1 end

  -- clamp the paddles to the screen
  p1_y = mid(8, p1_y, 68)
  p2_y = mid(8, p2_y, 68)

  -- move the ball
  ball_x += ball_vx
  ball_y += ball_vy

  -- bounce the ball off the paddles
  if ball_x < 3 and ball_y > p1_y-4 and ball_y < p1_y+4 then
    ball_vx = -ball_vx
    sfx(1)
  end
  if ball_x > 123 and ball_y > p2_y-4 and ball_y < p2_y+4 then
    ball_vx = -ball_vx
    sfx(1)
  end

  -- bounce the ball off the top and bottom of the screen
  if ball_y < 0 then
    ball_vy = -ball_vy
    sfx(0)
  end
  if ball_y > 72 then
    ball_vy = -ball_vy
    sfx(0)
  end
    if ball_x < 0 then
    sfx(2)
    p2_score += 1
    ball_x = 64
    ball_y = 36
    ball_vx = 1
    ball_vy = 1
  end
   if ball_x > 128 then
   sfx(2)
    p1_score += 1
    ball_x = 64
    ball_y = 36
    ball_vx = -1
    ball_vy = 1
    -- check for game over
  if p1_score >= 10 or p2_score >= 10 then
    -- check for input to restart the game
    if btn(4) or btn(5) then
      p1_score = 0
      p2_score = 0
      ball_x = 64
      ball_y = 36
      ball_vx = 1
      ball_vy = 1
    end
  end
  end
end

function _draw()
cls()
-- check the game state
  if game_state == "start" then
    -- clear the screen
    cls()

    -- display the start screen
    print("gpt-pong", 48, 24, 7)
    print("credits: by. chatgpt", 32, 36, 7)
    print("press x or o to start game", 24, 48, 7)
  elseif game_state == "play" then
  cls()
  -- draw the paddles and ball
  rectfill(0, p1_y-4, 2, p1_y+4, 7)
  rectfill(126, p2_y-4, 128, p2_y+4, 7)
  circfill(ball_x, ball_y, 2, 7)

		-- draws the player scores
print(p1_score, 4, 2, 7)
  print(p2_score, 118, 2, 7)
-- check for game over
  if p1_score >= 10 or p2_score >= 10 then
    -- clear the screen
    cls()

    -- display the winner
    if p1_score >= 10 then
      print("player 1 wins!", 32, 36, 7)
    else
      print("player 2 wins!", 32, 36, 7)
    end

    -- display the restart message
    print("press x or o to restart the game", 32, 48, 7)
  end
end
end
1


OK, it's time to let ChatGPT write itself.😂


This was fun, thank u! I found it especially amusing to play pong against myself as punishment for being curious if AI could make a pico-8 game. There are so many layers of ridiculous here, that it ended up being true peice of interactive art! Playing pong against yourself is similar to asking AI to create what u want. It's a reflection of your intention in the way pong is a mirror of itself.



[Please log in to post a comment]