GLBasic forum

Main forum => Tutorials => Topic started by: Kitty Hello on 2023-Apr-21

Title: Chat.GPT
Post by: Kitty Hello on 2023-Apr-21
I asked Chat:GPT to write a GLBasic program, that shows a starfield, and, with the exception of CLS instead of CLEARSCREEN, it just worked out of the box. Awesome :)
Title: Re: Chat.GPT
Post by: bigsofty on 2023-Apr-22
Wow, kinda scarey but wow!  :blink:
Title: Re: Chat.GPT
Post by: Qedo on 2023-Apr-22
So is our fun over? let's hope that at least the imagination is lacking
Title: Re: Chat.GPT
Post by: Kitty Hello on 2023-Apr-27
I think it's a good addition to the manual. But it's never going to create a game. Especially if you have a new idea.
Title: Re: Chat.GPT
Post by: loftcat on 2023-May-22
Ooh that's good. I'm amazed it recognises languages out of the mainstream. Could be useful for when I forget little bits of syntax.
Title: Re: Chat.GPT
Post by: Hemlos on 2023-Jun-11
Chatgpt is my buddy  :booze:

Note, it even gave example  :nw:
Me to ChatGPT:
QuoteI need a math formula, GLBasic TYPE coding, planet orbit physics, for finding the Orbital Semi-Major Axis.


Code (glbasic) Select
TYPE Orbit
    average_distance%  // Average distance between the planet and its central body
    eccentricity%     // Eccentricity of the orbit

    FUNCTION CalculateSemiMajorAxis: ()
        LOCAL semi_major_axis
        semi_major_axis = (2 * average_distance%) / (1 - POW(eccentricity%, 2))
        RETURN semi_major_axis
    ENDFUNCTION
ENDTYPE

// Usage example
GLOBAL Orbit AS Orbit
Orbit.average_distance = 10  // Example value for average_distance
Orbit.eccentricity = 0.5    // Example value for eccentricity

LOCAL semi_major_axis
semi_major_axis = Orbit.CalculateSemiMajorAxis()
PRINT "Semi-Major Axis: " + semi_major_axis


This is wrong, FUNCTION CalculateSemiMajorAxis: ()
But ill let it slide by this time.

Title: Re: Chat.GPT
Post by: Quentin on 2023-Jul-29
quite interesting. I asked to it to create a pong game for GLBasic and it seems, it is able to learn. But sometimes it's hard to explain exactly what I mean  =D

see chat her:
https://chat.openai.com/share/3cbbfac1-3880-4b40-a513-827b9eba91cd
Title: Re: Chat.GPT
Post by: Kitty Hello on 2023-Aug-23
It did write a complete game of Pong!? That's so insane.
Title: Re: Chat.GPT
Post by: dreamerman on 2023-Sep-09
All that AI stuff evolved so much in couple last years.. We are on the verge of revolution in many aspects of creative work, such AI tools will replace many 'creative' professions and on other hand will create new ones.. Imagine if someone is writing a legit book and need some art for cover or as illustrations for new chapters, now he can use MindJurney by him self and get something interesting, on other hand artist can use such tools to fastly generate many different visions/sketches of some client idea and later use it as base for further work and so on.. AI can now write basic books (like motivation, biography, books for kids), but will not write large series or universe that makes cross reference (like Cosmere - by Brandon Sanderson), but could be used for new ideas or to make parts of narration. Maybe it would be usefully in writing some parts of more advanced code not only simpler examples (but fact that it already can write a working game in such niche language as GLB is stunning).

On my hand I'm interested in game asset creation, more particular sprites with animation or something that would be usefull in a game, yet still such AI models need a lot of training in that direction (and of course it will be hard to deliver competitive art for them). Those are couple examples generated with Leonardo AI (https://leonardo.ai/) with different creation models:
Title: Re: Chat.GPT
Post by: MrPlow on 2023-Nov-20
Wow! It knows GLBasic...
Yes, I have done a few assets examples too...
Title: Re: Chat.GPT
Post by: MrPlow on 2023-Nov-20
Hi I asked GPT to create GUI menu in GLBasic and it gave me

Code (glbasic) Select
// Set the screen dimensions
SCREEN 800, 600, 0, 2

// Define menu constants
CONST MENU_ITEM_HEIGHT = 50
CONST MENU_TEXT_SIZE = 20

// Define menu items
GLOBAL menuItems[2] = ["Option 1", "Option 2"]
GLOBAL selectedMenuItem = -1

// Main loop
WHILE TRUE
  // Clear the screen
  CLS RGB(255, 255, 255)

  // Draw menu items
  FOR i = 0 TO UBOUND(menuItems)
    LOCAL itemY = i * MENU_ITEM_HEIGHT + 10
    RECT 10, itemY, 790, itemY + MENU_ITEM_HEIGHT, RGB(200, 200, 200)
    PRINT menuItems[i], 20, itemY + 10, MENU_TEXT_SIZE
  NEXT

  // Check for mouse input
  LOCAL mouseX, mouseY, mouseButton
  MOUSESTATE mouseX, mouseY, mouseButton

  // Highlight the selected menu item
  selectedMenuItem = -1
  FOR i = 0 TO UBOUND(menuItems)
    LOCAL itemY = i * MENU_ITEM_HEIGHT + 10
    IF mouseX > 10 AND mouseX < 790 AND mouseY > itemY AND mouseY < itemY + MENU_ITEM_HEIGHT
      RECT 10, itemY, 790, itemY + MENU_ITEM_HEIGHT, RGB(150, 150, 150)
      selectedMenuItem = i
    ENDIF
  NEXT

  // Check for mouse click on a menu item
  IF mouseButton = 1 AND selectedMenuItem <> -1
    // Perform action based on the selected menu item
    SELECT selectedMenuItem
      CASE 0
        PRINT "Option 1 selected", 400, 300
      CASE 1
        PRINT "Option 2 selected", 400, 300
    END SELECT
    SLEEP 1000  // Display the message for a short time
  ENDIF

  // Refresh the screen
  SHOWSCREEN
WEND

// End the program
END



Needed some fixing but the example was close -  :o

Code (glbasic) Select
SUB main2:
LOADFONz("bigscore.png",1)
SETFONT 1
// Set the screen dimensions
//SCREEN 800, 600, 0, 2

// Define menu constants
CONSTANT MENU_ITEM_HEIGHT = 50
CONSTANT MENU_TEXT_SIZE = 20

// Define menu items
GLOBAL menuItems$[]
DIM menuItems$[2]
menuItems$[0]="Option 1"
menuItems$[1]="Option 2"
GLOBAL selectedMenuItem = -1

// Main loop
WHILE TRUE
  // Clear the screen
  CLEARSCREEN RGB(255, 255, 255)

  // Draw menu items
  FOR i = 0 TO LEN(menuItems$[])-1
    LOCAL itemY = i * MENU_ITEM_HEIGHT + 10
    DRAWRECT 10, itemY, 790, itemY + MENU_ITEM_HEIGHT, RGB(200, 200, 200)
    PRINT menuItems$[i], 20, itemY + 10, MENU_TEXT_SIZE
  NEXT

  // Check for mouse input
  LOCAL mouseX, mouseY, mouseButton,mb2
  MOUSESTATE mouseX, mouseY, mouseButton,mb2

  // Highlight the selected menu item
  selectedMenuItem = -1
  FOR i = 0 TO LEN(menuItems$[])-1
    LOCAL itemY = i * MENU_ITEM_HEIGHT + 10
    IF mouseX > 10 AND mouseX < 790 AND mouseY > itemY AND mouseY < itemY + MENU_ITEM_HEIGHT
      DRAWRECT 10, itemY, 790, itemY + MENU_ITEM_HEIGHT, RGB(150, 150, 150)
      selectedMenuItem = i
    ENDIF
  NEXT

  // Check for mouse click on a menu item
  IF mouseButton = 1 AND selectedMenuItem <> -1
    // Perform action based on the selected menu item
    SELECT selectedMenuItem
      CASE 0
        PRINT "Option 1 selected", 400, 300
      CASE 1
        PRINT "Option 2 selected", 400, 300
    ENDSELECT
    SLEEP 1000  // Display the message for a short time
  ENDIF

  // Refresh the screen
  SHOWSCREEN
WEND

// End the program
ENDSUB
Title: Re: Chat.GPT
Post by: Qedo on 2023-Nov-22
Great, but Chat.GPT needs to study the syntax of Glbasic better  =D