I asked it first to create the Hello World code, but every commandline was wrong. It does have a learning function, but even after correcting it and suggested a workinging example (twice), it still insisted in providing that wrong code.
Then I asked it to provide the code for a simple Pong game and this is what I got
Code: Select all
; Pong game in Hollywood
; Set up the window
OpenWindow(0, 0, 300, 200, "Pong", #PB_Window_SystemMenu)
; Variables for ball position and velocity
BallX = 150 : BallY = 100
BallVX = 2 : BallVY = 2
; Variables for paddle positions
Paddle1Y = 75 : Paddle2Y = 75
; Main game loop
Repeat
; Clear the screen
ClearScreen()
; Move the ball
BallX = BallX + BallVX
BallY = BallY + BallVY
; Bounce the ball off the top and bottom walls
If BallY < 0 Or BallY > 190
BallVY = -BallVY
EndIf
; Check for paddle collisions
If BallX < 20 And BallY > Paddle1Y And BallY < Paddle1Y + 50
BallVX = -BallVX
EndIf
If BallX > 280 And BallY > Paddle2Y And BallY < Paddle2Y + 50
BallVX = -BallVX
EndIf
; Check for scoring
If BallX < 0
MessageRequester("Player 2 wins!", "Score")
BallX = 150 : BallY = 100
EndIf
If BallX > 300
MessageRequester("Player 1 wins!", "Score")
BallX = 150 : BallY = 100
EndIf
; Draw the ball
DrawCircle(BallX, BallY, 5, #PB_Pixel_Red)
; Draw the paddles
DrawRectangle(10, Paddle1Y, 10, 50, #PB_Pixel_White)
DrawRectangle(280, Paddle2Y, 10, 50, #PB_Pixel_White)
; Move the paddles with the mouse
Paddle1Y = MouseY() - 25
Paddle2Y = BallY - 25
; Update the screen
UpdateWindow()
Forever
I have commented the non-working lines and created the working code below each line
Code: Select all
; Pong game in Hollywood
; Set up the window
;OpenWindow(0, 0, 300, 200, "Pong", #PB_Window_SystemMenu)
@DISPLAY{Y = 0, X = 0, WIDTH=300,HEIGHT=200, Title = "PONG"}
; Variables for ball position and velocity
;BallX = 150 : BallY = 100
BallX = 150
BallY = 100
;BallVX = 2 : BallVY = 2
BallVX = 2
BallVY = 2
; Variables for paddle positions
;Paddle1Y = 75 : Paddle2Y = 75
Paddle1Y = 75
Paddle2Y = 75
; Main game loop
Repeat
; Clear the screen
;ClearScreen()
Cls
; Move the ball
BallX = BallX + BallVX
BallY = BallY + BallVY
; Bounce the ball off the top and bottom walls
If BallY < 0 Or BallY > 190
BallVY = -BallVY
EndIf
; Check for paddle collisions
If BallX < 20 And BallY > Paddle1Y And BallY < Paddle1Y + 50
BallVX = -BallVX
EndIf
If BallX > 280 And BallY > Paddle2Y And BallY < Paddle2Y + 50
BallVX = -BallVX
EndIf
; Check for scoring
If BallX < 0
;MessageRequester("Player 2 wins!", "Score")
SystemRequest("Player 2 wins!", "Score", "OK")
;BallX = 150 : BallY = 100
BallX = 150
BallY = 100
EndIf
If BallX > 300
;MessageRequester("Player 1 wins!", "Score")
SystemRequest("Player 1 wins!", "Score", "OK")
;BallX = 150 : BallY = 100
BallX = 150
BallY = 100
EndIf
; Draw the ball
;DrawCircle(BallX, BallY, 5, #PB_Pixel_Red)
Circle(BallX, BallY, 5, #RED)
; Draw the paddles
;DrawRectangle(10, Paddle1Y, 10, 50, #PB_Pixel_White)
Box(10, Paddle1Y, 10, 50, #WHITE)
;DrawRectangle(280, Paddle2Y, 10, 50, #PB_Pixel_White)
Box(280, Paddle2Y, 10, 50, #WHITE)
; Move the paddles with the mouse
Paddle1Y = MouseY() - 25
Paddle2Y = BallY - 25
; Update the screen
;UpdateWindow()
VWait()
Forever