Weekly Qbasic and Qb64 Lesson Topics
March 28, 2024, 04:23:28 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  

Weekly Lesson More Advanced, QB64 1st lesson

Pages: [1]
  Print  
Author Topic: Weekly Lesson More Advanced, QB64 1st lesson  (Read 1674 times)
GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« on: January 10, 2011, 08:26:32 pm »

 These are 8 lessons,(Demos)  Useing a still unfinished game
as the example, as the Game gets updated,there will be more lessons, at this time there are 8. http://dl.dropbox.com/u/15387474/GameLearn1to8.rar Is the
complete package with all 8 lessons, the 8th being the result of what the others lead up to, a   working model of the planned game. All though there are some fine tuneing adjustments still needed. Each lesson is in a .BAS code format, that can be run useing QB64. It should be noted that to use the Graphics, you will also need these images, at drop box:
http://dl.dropbox.com/u/15387474/Rabbit4.bmp
http://dl.dropbox.com/u/15387474/CliffinClouds.bmp
http://dl.dropbox.com/u/15387474/Hawk_sprite.bmp
Quote
   REM GameLearn001
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background

DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor

Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
WorkPage& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page

DO
    _LIMIT 30 '30 frames per second
    _PUTIMAGE , Background&, Video& 'copy the background onto the video page
    _DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM
 
Ok  that is about it, for now. And many thanks to a person for his work and effort in putting these lessons together.
« Last Edit: September 07, 2011, 09:45:00 pm by GarrisonRicketson » Report Spam   Logged

Share on Facebook Share on Twitter

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #1 on: February 04, 2011, 07:49:32 am »

GameLearn002
Code:
     REM GameLearn002
'Lets show the hawk graphics over the background
'Demonstaarte clearcolor
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor
LOCATE 20, 1: PRINT "this line -->SCREEN Video&<-- created this output screen window"
_DELAY 1


Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page


_LIMIT 30 '30 frames per second

PRINT "Press a key to see background"
Dummy$ = INPUT$(1)
_PUTIMAGE , Background&, Video& 'copy the background onto the video page
LOCATE 20, 1: PRINT "this line -->_PUTIMAGE , Background&, Video&<-- showed the bg on monitor"

_DELAY 1
PRINT "Press a key to see hawk graphics"
Dummy$ = INPUT$(1)
_PUTIMAGE (100, 100)-(275, 160), Graphics&, Video& 'copy the hawks over the background
LOCATE 20, 1: PRINT "this line ->_PUTIMAGE (100, 100)-(275, 160), Graphics&, Video&<- showed the hawks on monitor"

_DELAY 1
PRINT "Press a key to see hawk graphics with clearcolor"
Dummy$ = INPUT$(1)
_PUTIMAGE , Background&, Video& 'copy the background onto the video page
_CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)
_PUTIMAGE (100, 100)-(275, 160), Graphics&, Video& 'copy the hawks over the background

LOCATE 20, 1
PRINT "this line ->_PUTIMAGE , Background&, Video&<- showed the bg on monitor"
PRINT "This line ->_CLEARCOLOR 0, Graphics&<- declared the clearcolor is 0(zero) on Graphics page"
PRINT "this lines ->_PUTIMAGE (100, 100)-(275, 160), Graphics&, Video&<- showed the hawks on monitor"

_DELAY 1
PRINT "Press a key to EXIT"

SLEEP
SYSTEM

 
« Last Edit: September 07, 2011, 09:46:02 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #2 on: February 04, 2011, 07:55:48 am »

GameLearn003,

Code:
    REM GameLearn003
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background
'Show hawk animation
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor

Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page

cycle = 0 'variable to indicate the frame of hawk graphic to use

DO
    cycle = cycle + 1 'increment cycle variable
    IF cycle >= 3 THEN cycle = 1 'cycle is 1 or 2 , used to indicate which frame of hawk to show

    _LIMIT 30 '30 frames per second

    _PUTIMAGE , Background&, Video& 'copy the background onto the video page clearing the screen
    _CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)

    SELECT CASE cycle 'logic branch based on what cycle is
        CASE 1
            _PUTIMAGE (100, 100)-(187, 159), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background
        CASE 2
            _PUTIMAGE (100, 100)-(187, 159), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background
    END SELECT

    LOCATE 20, 1: PRINT " The hawk animation is achieved by showing each frame one after another"
    PRINT "_putimage(DESTINATION co-ords),SourcePage,DestinationPage,(SOURCE co-ords)"
    PRINT "The destination co-ords stay the same =(100, 100)-(187, 159) "
    PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) "

    _DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM

 
« Last Edit: September 07, 2011, 09:46:35 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #3 on: February 07, 2011, 07:57:12 pm »

This is Gamelearn 004
Code:
REM GameLearn004
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background
'Show hawk animation, create master hawk X and Y for screen placement
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor

Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page

cycle = 0 'variable to indicate the frame of hawk graphic to use
hX = 100: hY = 100
DO
    cycle = cycle + 1 'increment cycle variable
    IF cycle >= 3 THEN cycle = 1 'cycle is 1 or 2 , used to indicate which frame of hawk to show

    _LIMIT 30 '30 frames per second

    _PUTIMAGE , Background&, Video& 'copy the background onto the video page clearing the screen
    _CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)

    SELECT CASE cycle 'logic branch based on what cycle is
        CASE 1
            _PUTIMAGE (hX, hY), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background
        CASE 2
            _PUTIMAGE (hX, hY), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background
    END SELECT

    LOCATE 20, 1: PRINT " Note the hawk DESTINATION co-ords are (hX, hY)"
    PRINT "_putimage (hX, hY),SourcePage,DestinationPage,(SOURCE co-ords)"
    PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) "

    _DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM

 

 
« Last Edit: September 07, 2011, 09:47:08 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #4 on: February 07, 2011, 08:06:03 pm »

GameLearn005,
Code:
   REM GameLearn005
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background
'Show hawk animation, create master hawk X and Y for screen placement
'Create a sub to move the hawk horizontally
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor

Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page

cycle = 0 'variable to indicate the frame of hawk graphic to use
hX = 100: hY = 100: hdir = 1 'hdir =hawk direction 1=east , -1=west
DO
    cycle = cycle + 1 'increment cycle variable
    IF cycle >= 3 THEN cycle = 1 'cycle is 1 or 2 , used to indicate which frame of hawk to show
    hX = hX + hdir 'increment the X every cycle
    IF hX >= 630 THEN hX = 630: hdir = -1 'test collision with right side, toggle hdir to minus
    IF hX <= 10 THEN hX = 10: hdir = 1 'test collision with left side, toggle hdir to plus
    _LIMIT 30 '30 frames per second

    _PUTIMAGE , Background&, Video& 'copy the background onto the video page clearing the screen
    _CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)

    SELECT CASE cycle 'logic branch based on what cycle is
        CASE 1
            _PUTIMAGE (hX, hY), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background
        CASE 2
            _PUTIMAGE (hX, hY), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background
    END SELECT

    LOCATE 20, 1: PRINT " Note the hawk DESTINATION co-ords are (hX, hY) and hdir="; hdir
    PRINT "_putimage ("; hX; ","; hY; "),SourcePage,DestinationPage,(SOURCE co-ords)"
    PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) "

    _DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM

« Last Edit: September 07, 2011, 09:47:38 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #5 on: February 07, 2011, 08:25:15 pm »

GameLearn006
Code:
   REM GameLearn006
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background
'Show hawk animation, create master hawk X and Y for screen placement
'Create a sub to move the hawk horizontally
'Create a sub to move the hawk vertically
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor

Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page

cycle = 0 'variable to indicate the frame of hawk graphic to use
hX = 100: hY = 100
hhdir = 1 'hhdir =hawk direction 1=east , -1=west
hvdir = 1 'hvdir =hawk direction 1=down , -1=up
DO
    cycle = cycle + 1 'increment cycle variable
    IF cycle >= 3 THEN cycle = 1 'cycle is 1 or 2 , used to indicate which frame of hawk to show
    GOSUB MoveHawk
    _LIMIT 30 '30 frames per second

    _PUTIMAGE , Background&, Video& 'copy the background onto the video page clearing the screen
    _CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)

    SELECT CASE cycle 'logic branch based on what cycle is
        CASE 1
            _PUTIMAGE (hX, hY), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background
        CASE 2
            _PUTIMAGE (hX, hY), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background
    END SELECT

    LOCATE 20, 1: PRINT " Note the hawk DESTINATION co-ords are (hX, hY) and hhdir="; hhdir; "hvdir="; hvdir
    PRINT "_putimage ("; hX; ","; hY; "),SourcePage,DestinationPage,(SOURCE co-ords)"
    PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) "

    _DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM

MoveHawk:
hX = hX + hhdir 'increment the X every cycle
IF hX >= 630 THEN hX = 630: hhdir = -1 'test collision with right side, toggle hhdir to minus
IF hX <= 10 THEN hX = 10: hhdir = 1 'test collision with left side, toggle hhdir to plus

hY = hY + hvdir
IF hY >= 470 THEN hY = 470: hvdir = -1
IF hY <= 10 THEN hY = 10: hvdir = 1
RETURN
 
« Last Edit: September 07, 2011, 09:48:05 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #6 on: February 07, 2011, 08:47:24 pm »

GameLearn007
Code:
    REM GameLearn007
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background
'Show hawk animation, create master hawk X and Y for screen placement
'create a sub to move hawk horizontally and vertically with the arrow keys
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor

Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page

cycle = 0 'variable to indicate the frame of hawk graphic to use
hX = 100: hY = 100
hhdir = 1 'hhdir =hawk direction 1=east , -1=west
hvdir = 1 'hvdir =hawk direction 1=down , -1=up
DO
    cycle = cycle + 1 'increment cycle variable
    IF cycle >= 3 THEN cycle = 1 'cycle is 1 or 2 , used to indicate which frame of hawk to show
    GOSUB Getkey
    GOSUB MoveHawk
    _LIMIT 30 '30 frames per second

    _PUTIMAGE , Background&, Video& 'copy the background onto the video page clearing the screen
    _CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)

    SELECT CASE cycle 'logic branch based on what cycle is
        CASE 1
            _PUTIMAGE (hX, hY), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background
        CASE 2
            _PUTIMAGE (hX, hY), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background
    END SELECT

    LOCATE 20, 1: PRINT "Use arrow keys to move HAWK"
    PRINT " Note the hawk DESTINATION co-ords are (hX, hY) and hhdir="; hhdir; "hvdir="; hvdir
    PRINT "_putimage ("; hX; ","; hY; "),SourcePage,DestinationPage,(SOURCE co-ords)"
    PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) "

    _DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM

MoveHawk:
'Horizontal (L and R)collision tests
IF hX >= 630 THEN hX = 630: hhdir = -1 'test collision with right side, toggle hhdir to minus
IF hX <= 10 THEN hX = 10: hhdir = 1 'test collision with left side, toggle hhdir to plus

'Vertical (U and D)collision tests
IF hY >= 470 THEN hY = 470: hvdir = -1
IF hY <= 10 THEN hY = 10: hvdir = 1
RETURN

Getkey:
'Arrow keys
IF _KEYDOWN(20480) THEN hY = hY + 1 'down arrow key so add 1
IF _KEYDOWN(18432) THEN hY = hY - 1 'up arrow key so minus 1
IF _KEYDOWN(19200) THEN hX = hX - 1 'left arrow key so minus 1
IF _KEYDOWN(19712) THEN hX = hX + 1 'right arrow key so add 1

IF _KEYDOWN(32) THEN Wantacapture = True 'spacebar
IF _KEYDOWN(100305) THEN Wantarelease = True 'right control button
RETURN
 
« Last Edit: September 07, 2011, 09:49:31 pm by GarrisonRicketson » Report Spam   Logged

GarrisonRicketson
Admin
Administrator
Hero Member
*****
Posts: 583



WWW
« Reply #7 on: February 07, 2011, 09:05:32 pm »

Gamelearn008
Code:
   REM GameLearn008
'Demonstartes creating image surfaces,loading graphics to those pages
'Create a game loop and shows the background
'Show hawk animation, create master hawk X and Y for screen placement
'create a sub to move hawk horizontally and vertically with the arrow keys
'Create a YELLOW OBJECT that hawk can capture
'Create a PINK BOUNDARY BOX below hawks claws
'Make sound when boxes intersect!!
DEFLNG A-Z 'any variable with a name starting with the letters a throught to z are LONG types

CONST True = -1, False = NOT (True) 'constants for logic


Video& = _NEWIMAGE(640, 480, 32) 'screen 12 size 32bit colors
SCREEN Video& 'make this the surface the user sees on monitor

Background& = _LOADIMAGE("Cliffinclouds.bmp") 'create the background page
Graphics& = _LOADIMAGE("Hawk_sprite.bmp") 'create the sprite sheet page

Yellow& = _RGB32(255, 255, 0) 'the 32 bit yellow color
Pink& = _RGB32(255, 0, 255)
cycle = 0 'variable to indicate the frame of hawk graphic to use
hX = 100: hY = 100
hhdir = 1 'hhdir =hawk direction 1=east , -1=west
hvdir = 1 'hvdir =hawk direction 1=down , -1=up
Object = 1 'object at rest  =1,captured =2,released and falling =3
Showbox = True: Captured = False

DO
    cycle = cycle + 1 'increment cycle variable
    IF cycle >= 3 THEN cycle = 1 'cycle is 1 or 2 , used to indicate which frame of hawk to show
    GOSUB Getkey
    GOSUB MoveHawk
    _LIMIT 30 '30 frames per second

    _PUTIMAGE , Background&, Video& 'copy the background onto the video page clearing the screen
    _CLEARCOLOR 0, Graphics& 'set clearcolor to black(background color on hawk sprite page)

    SELECT CASE cycle 'logic branch based on what cycle is
        CASE 1
            _PUTIMAGE (hX, hY), Graphics&, Video&, (0, 0)-(87, 59) 'copy the hawks over the background
        CASE 2
            _PUTIMAGE (hX, hY), Graphics&, Video&, (88, 0)-(174, 59) 'copy the hawks over the background
    END SELECT

    LOCATE 20, 1: PRINT "Use arrow keys to move HAWK"
    PRINT " Note the hawk DESTINATION co-ords are (hX, hY) and hhdir="; hhdir; "hvdir="; hvdir
    PRINT "_putimage ("; hX; ","; hY; "),SourcePage,DestinationPage,(SOURCE co-ords)"
    PRINT "The source co-ords change,Frame1=(0, 0)-(87, 59),Frame2=(88, 0)-(174, 59) "
    PRINT chx1, chx2, chy1, chY2, "Yellow circle disappears if bunny captured!"
    IF Showbox = True THEN GOSUB HawkBoundaryBox
    GOSUB Hawkcollision
    IF Captured = False THEN
        CIRCLE (320, 470), 5, Yellow&
        CIRCLE (320, 470), 4, Yellow&
    END IF
    _DISPLAY 'update the monitor
LOOP UNTIL _KEYDOWN(27) 'escape key to exit
SLEEP
SYSTEM

MoveHawk:
'Horizontal (L and R)collision tests
IF hX >= 630 THEN hX = 630: hhdir = -1 'test collision with right side, toggle hhdir to minus
IF hX <= 10 THEN hX = 10: hhdir = 1 'test collision with left side, toggle hhdir to plus

'Vertical (U and D)collision tests
IF hY >= 470 THEN hY = 470: hvdir = -1
IF hY <= 10 THEN hY = 10: hvdir = 1
RETURN

Getkey:
'Arrow keys
IF _KEYDOWN(20480) THEN hY = hY + 1 'down arrow key so add 1
IF _KEYDOWN(18432) THEN hY = hY - 1 'up arrow key so minus 1
IF _KEYDOWN(19200) THEN hX = hX - 1 'left arrow key so minus 1
IF _KEYDOWN(19712) THEN hX = hX + 1 'right arrow key so add 1

IF _KEYDOWN(32) THEN Wantacapture = True 'spacebar
IF _KEYDOWN(100305) THEN Wantarelease = True 'right control button
RETURN

HawkBoundaryBox:
chx1 = hX + 38: chx2 = hX + 58: chy1 = hY + 44: chY2 = hY + 48 'used to monitor onscreen
LINE (hX + 38, hY + 44)-(hX + 58, hY + 52), Pink&, B 'hawks boundary box of his claws
'LINE (bx - 5, 395)-(bx + 5, 405), ORed&, B
RETURN

Hawkcollision:
IF hX + 38 >= 306 AND hX + 58 <= 334 THEN 'this is 14 before and 14 after centre of circle on x axis
    'SOUND 2000, 1
    IF hY + 44 >= 462 AND hY + 48 <= 470 THEN 'this is 8 before and up to the centre of circle
        SOUND 3000, 1
        'check if capture key is down
        'if so then register captured variable as TRUE
        Captured = True
        'next assign circle x and y as some offset of hX and hY figures
        'this way circle can be drawn under hawks feet even if hawk moves!
    END IF
END IF
RETURN
 
« Last Edit: September 07, 2011, 09:50:03 pm by GarrisonRicketson » Report Spam   Logged


Pages: [1]
  Print  
 
Jump to:  

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


Powered by SMF | SMF © 2016, Simple Machines
Privacy Policy