Hi
I am new to the exciting world of QB64. Just starting work on a invaders style game as a way to learn, in the game before you get to shoot anything you need to land your spaceship. So I have written a couple of subs to generate a random channel that the player will have fly down.
Is there a way to paint textures as well as solid colours?
'Program to test drawing a random channel for lander mini game
'-------------------------------------------------------------
'Declare cords of the lefthand side of the channel mouth
'-------------------------------------------------------
'calculate cords of the lefthand side of the channel mouth
'---------------------------------------------------------
'lastX = 0
'lastY = 100
newY = 100
DrawDownRndChan newX
, newY
, _HEIGHT - 1, 64, qbWHITE
'Paint the sides of the channel
'------------------------------
PAINT (newX
- 50, newY
+ 10), qbGREY
, qbWHITE
' Draw a channel down the screen in a randowm fashion to simulate a rocky terrain
'--------------------------------------------------------------------------------
'
'/\/\//////\///\//// \/\///\/\/\/\/\/\/\/
' | /
' \ \
' \ \
'--------------------------------------------------------------------------------
'Parameters
'startX, startY cords of the lefthand side of the channel opening
'minWidth the minimum width of the channel
'lineColour rgb colour to draw the lines
'Calls
'calls sub DrawRightRnd to draw wiggly horizontal line from the edges of the screen to the mouth of the channel
DIM lastX
, lastRx
AS SINGLE ' end point of the last line DIM newX
, newRx
AS SINGLE ' next x cord either side of the channel
newX = startX
newY = startY
lastRx
= startX
+ minWidth
+ (RND * 10) 'calc inital width of the channel newRx = lastRx
'draw wiggly line from the sides of the screen to the mouth of the channel
LineHorizRnd 0, startY, startX, startY, lineColour
LineHorizRnd lastRx
, startY
, _WIDTH - 1, startY
, lineColour
'Channel drawing loop
'--------------------
lastX = newX
lastY = newY
lastRx = newRx
newX
= lastX
+ (RND * 40 - 20) newRx
= newX
+ minWidth
+ (RND * 10) newY = maxY
LINE (lastX
, lastY
)-(newX
, newY
), lineColour
' draw lefthand section of channel LINE (lastRx
, lastY
)-(newRx
, newY
), lineColour
' draw rigthand section of channel
'draw a wiggly horizontal line from left to right
'------------------------------------------------
PSET (startX
, startY
), lineColour
' Set the start point for the line
newX = startX
newY = startY
'Main line drawing loop
'----------------------
newX
= newX
+ (RND * 30) + 10 newY
= startY
+ (RND * 20 - 10) IF newX
>= endX
THEN ' make sure we end at the right place newX = endX
newY = endY
LINE -(newX
, newY
), lineColour