Weekly Qbasic and Qb64 Lesson Topics
January 22, 2018, 04:09:33 pm
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Want to see a specific Tutorial? ASK!
 
  Home Help Search Arcade Links Staff List Login Register  

Conventional v Library


Pages: [1]
  Print  
Author Topic: Conventional v Library  (Read 178 times)
OlDosLover
Guest
« on: March 14, 2011, 06:20:55 pm »

Hi all,
    Here's a demo made by unseen to compare his Library to conventional ways of coding.
One
Code:
'// GDK Comparisons - The mouse

SCREEN _NEWIMAGE(800, 600, 32)


'// The standard method.

'// Create normal integer variables to hold mouse position and buttonstate
DIM Mx AS INTEGER, My AS INTEGER, LMB AS INTEGER, RMB AS INTEGER

DO

  DO WHILE _MOUSEINPUT
    Mx = _MOUSEX
    My = _MOUSEY
    LMB = _MOUSEBUTTON(1)
    RMB = _MOUSEBUTTON(2)
  LOOP

  LOCATE 1, 1: PRINT Mx, My, LMB, RMB
  _DISPLAY
  CLS

LOOP UNTIL INKEY$ = CHR$(27)



'GDK Method

'// Create a type array to hold the mouse data
DIM Mouse AS MouseState

DO

  GDK_GetMouseState Mouse
  LOCATE 1, 1: PRINT Mouse.Mx, Mouse.My, Mouse.LMB, Mouse.RMB
  _DISPLAY
  CLS

LOOP UNTIL INKEY$ = CHR$(27)



REM$INCLUDE:'UnseenGDK03.bm'

Two
Code:
'/ GDK - Comparisons

'// Keyboard input

'Normal Method - Using Scankeys

'// This code modded from wiki on scankeys

CLS
LOCATE 1, 1: PRINT "ARROW PAD"
DO: _LIMIT 1000 ' program or game loop
  IF ScanKey%(72) THEN LOCATE 2, 55: PRINT " UP " ELSE LOCATE 2, 55: PRINT "----" 'arrow
  IF ScanKey%(80) THEN LOCATE 6, 55: PRINT "DOWN" ELSE LOCATE 6, 55: PRINT "----" 'arrow
  IF ScanKey%(75) THEN LOCATE 4, 52: PRINT "LEFT" ELSE LOCATE 4, 52: PRINT "----" 'arrow
  IF ScanKey%(77) THEN LOCATE 4, 58: PRINT "RIGHT" ELSE LOCATE 4, 58: PRINT "---- " 'arrow
LOOP UNTIL ScanKey%(1)
zerocodes% = ScanKey%(0) 'reset all array values to zero for next part of program
END

Three
Code:
'// GDK Method

DIM Kb AS KeyBoardState

DO

  GDK_GetKeyboardState Kb

  LOCATE 1, 1: PRINT "Press an arrow key"
  IF Kb.Left THEN PRINT "left"
  IF Kb.Right THEN PRINT "right"
  IF Kb.Up THEN PRINT "up"
  IF Kb.Down THEN PRINT "down"

  _DISPLAY
  CLS

LOOP UNTIL Kb.ESC


REM $INCLUDE:'UnseenGDK03.bm'


    These are posted so the user can compare how something done conventionally is done in the Library.
OlDosLover.
Report Spam   Logged

Social Buttons


Pages: [1]
  Print  
 
Jump to:  

Powered by EzPortal
Bookmark this site! | Upgrade This Forum
SMF For Free - Create your own Forum

Buy traffic for your forum/website
traffic-masters
Powered by SMF | SMF © 2016, Simple Machines