Upgrade to Pro — share decks privately, control downloads, hide ads and more …

GameDev with QBasic

LD Smith
February 10, 2019

GameDev with QBasic

Video - https://youtu.be/CcdA_uz_GEQ
This month’s topic is game development history featuring QBasic. We discuss how we got started with game development and the first tools and languages that we used. Levi D. Smith shows how to setup QBasic using DOSBox and a brief overview of the language.

LD Smith

February 10, 2019
Tweet

More Decks by LD Smith

Other Decks in Technology

Transcript

  1. Running QBasic with DosBox • Install DOSBox • Recommended defaults

    • windowresolution=1024x768 • Output=opengl • [autoexec] mount C “C:\program files (x86)\DOSBox-0.74\qbasic” • Download Qbasic executable • Set default folder • C:\Users\<user>\AppData\Local\DOSBox\dosbox-<version>.conf • Filenames must be 8.3 format
  2. Example Qbasic Games • Before Internet access, all we had

    was looking at example code • Nibbles • Gorilla • Programming books weren’t prevalent at book stores • QBasic comes with built-in help pages
  3. Using QBasic • Shift + F5 - Run Game •

    F2 - View Subs • Alt, F, O - Load program • Ctrl + C - end program
  4. A Simple Game PRINT display text and variables INPUT read

    input from user DO WHILE / LOOP control structure IF THEN, ELSEIF, ELSE, END IF control structure >, <, <>, = comparison operators = assignment RANDOMIZE TIMER, RND generate random number INT cast as integer + Arithmetic
  5. Drawing Primitives – Lines and Rectangles • Screen Mode •

    SCREEN 7 – 320x200, 16 colors • SCREEN 12 – 640x480, 256K colors • Lines and Rectangles • From, To, Color, Type
  6. Drawing Primitives - Circles • Circles • Center, Radius, Color,

    Start Angle, End Angle, Aspect Ratio • Filled Circle • Paint – location, fill color, border color • Slow
  7. Drawing Shapes • Define pen movements (up, down, left, right,

    etc) with unit distance as a string • Use BM to set starting point
  8. Displaying Text • Use LOCATE x, y to set text

    position • PRINT to display strings and variables • Separate parameters with semicolon (;) • Comma (,) separated parameters will be extra spaced
  9. Playing Music • Use Play with string • O –

    Octave • L – Length • CDEFGAB – Notes • Sound (frequency, duration)
  10. Structures • TYPE to define structure • data types –

    INTEGER, LONG, SINGLE, DOUBLE, STRING • DIM to instantiate • Array – DIM foo(1 TO N) AS TYPE
  11. Procedures • F2 – show procedures • SUB – Sub

    procedure (does not return a value) • Can pass custom types (define type before sub declaration) • FUNCTION – Returns a value • Assign value to function name (don’t use “return”) • Global variable – use COMMON SHARED
  12. User Input • Read keyboard with INKEY$ • IBM PC

    Keyboard Scan Codes • http://www.jimprice.com/jim-asc.shtml#keycodes • Arrows • Up: CHR$(0) + CHR$(72) • Down: CHR$(0) + CHR$(80) • Right: CHR$(0) + CHR$(77) • Left: CHR$(0) + CHR$(75)