Welcome, Guest
You have to register before you can post on our site.

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 488
» Latest member: Bradynog
» Forum threads: 2,817
» Forum posts: 26,463

Full Statistics

Latest Threads
Playing sound files in QB...
Forum: Programs
Last Post: ahenry3068
7 minutes ago
» Replies: 1
» Views: 3
Forum PM is disabled.
Forum: Help Me!
Last Post: eoredson
2 hours ago
» Replies: 11
» Views: 89
What do you guys like to ...
Forum: General Discussion
Last Post: dano
3 hours ago
» Replies: 30
» Views: 798
I have a friend at IBM wh...
Forum: General Discussion
Last Post: SMcNeill
3 hours ago
» Replies: 8
» Views: 64
Exploring QB64-PE default...
Forum: Programs
Last Post: eoredson
5 hours ago
» Replies: 59
» Views: 2,450
FFT and IFFT
Forum: Petr
Last Post: Petr
6 hours ago
» Replies: 0
» Views: 21
building a more resilient...
Forum: Help Me!
Last Post: madscijr
9 hours ago
» Replies: 4
» Views: 67
Text Menu Library Project
Forum: Works in Progress
Last Post: Pete
Yesterday, 05:55 PM
» Replies: 3
» Views: 54
Bin2Data
Forum: a740g
Last Post: a740g
Yesterday, 11:41 AM
» Replies: 2
» Views: 315
How to Color Mask?
Forum: Help Me!
Last Post: bplus
Yesterday, 12:47 AM
» Replies: 3
» Views: 112

 
  A Small Game Tutorial (from 2014)
Posted by: SMcNeill - 11-13-2023, 06:21 AM - Forum: Programs - Replies (2)

Digging through some old junk on old drives once again, and I found more QB64 goodies.   This one is a HTML tutorial on making a little space avoidance type game, and from initial testing all still works as it should -- even after almost 10 years!  (This file was dated 6/6/2014 on my drive!)

The final version has you making this game:

Code: (Select All)
_TITLE "Space 64"

DIM asteroidx(100), asteroidy(100), asteroidspeed(100)

SCREEN 13



DATA 000,000,000,000,000,000,000,000,000,000
DATA 000,000,015,015,015,015,015,000,000,000
DATA 000,015,015,015,015,007,007,015,000,000
DATA 000,015,015,015,015,015,015,015,015,000
DATA 000,015,015,015,015,015,015,015,015,015
DATA 000,015,015,015,015,015,015,015,015,000
DATA 000,000,015,015,015,015,015,015,000,000
DATA 000,000,000,000,000,000,000,000,000,000
DATA 000,000,000,000,000,000,000,000,000,000
DATA 000,000,000,000,000,000,000,000,000,000

FOR y = 1 TO 10
FOR x = 1 TO 10

READ c
PSET (x, y), c
NEXT
NEXT

ship = _NEWIMAGE(11, 11, 13)

_PUTIMAGE (1, 1)-(10, 10), , ship, (1, 1)-(10, 10)

CLS

DATA 000,000,000,000,000,000,000,000,000,000
DATA 000,000,000,006,006,006,000,000,000,000
DATA 000,000,006,006,006,006,006,000,000,000
DATA 000,006,012,006,006,006,006,006,000,000
DATA 000,006,006,006,006,012,006,006,000,000
DATA 000,006,006,006,006,006,006,006,000,000
DATA 000,000,006,006,012,006,006,000,000,000
DATA 000,000,006,006,006,006,000,000,000,000
DATA 000,000,000,006,006,000,000,000,000,000
DATA 000,000,000,000,000,000,000,000,000,000

FOR y = 1 TO 10
FOR x = 1 TO 10

READ c
PSET (x, y), c
NEXT
NEXT

obstacle = _NEWIMAGE(11, 11, 13)

_PUTIMAGE (1, 1)-(10, 10), , obstacle, (1, 1)-(10, 10)

CLS

DATA 000,000,000,000,000,000,000,000,000,000
DATA 000,000,004,004,000,004,004,000,000,000
DATA 000,004,012,012,004,012,012,004,000,000
DATA 000,004,012,012,012,012,012,004,000,000
DATA 000,004,012,012,012,012,012,004,000,000
DATA 000,004,012,012,012,012,012,004,000,000
DATA 000,000,004,012,012,012,004,000,000,000
DATA 000,000,000,004,012,004,000,000,000,000
DATA 000,000,000,000,004,000,000,000,000,000
DATA 000,000,000,000,000,000,000,000,000,000


FOR y = 1 TO 10
FOR x = 1 TO 10

READ c
PSET (x, y), c
NEXT
NEXT

life = _NEWIMAGE(11, 11, 13)

_PUTIMAGE (1, 1)-(10, 10), , life, (1, 1)-(10, 10)

CLS

lives = 3

shipx = 10 'we set the x position of the ship to 10 and the y position is set
shipy = 95 'at the middle of the screen (middle of the ship is 5 hence 100-5=95).

DO

_LIMIT 60
CLS

IF explosion = 0 THEN
_PUTIMAGE (shipx, shipy), ship 'let's only display it when explosion = 0

'we can make some fire behind the ship by randomly setting some red pixels behind it.
FOR k = 1 TO 10: PSET (shipx - INT(RND * 5), shipy + INT(RND * 6) + 2), 4: NEXT
END IF


'display lives:
IF lives > 0 THEN
FOR k = 1 TO lives
_PUTIMAGE (k * 10, 0), life
NEXT

END IF

'display number of numbers collected:
_PRINTSTRING (0, 2), LTRIM$(STR$(collected))


IF _KEYDOWN(CVI(CHR$(0) + "H")) THEN shipy = shipy - 1
IF _KEYDOWN(CVI(CHR$(0) + "P")) THEN shipy = shipy + 1
IF _KEYDOWN(CVI(CHR$(0) + "K")) THEN shipx = shipx - 1
IF _KEYDOWN(CVI(CHR$(0) + "M")) THEN shipx = shipx + 1
IF _KEYDOWN(27) THEN END


IF shipx + 10 > 319 THEN shipx = 319 - 10
IF shipx < 0 THEN shipx = 0
IF shipy + 10 > 199 THEN shipy = 199 - 10
IF shipy < 0 THEN shipy = 0


IF numasteroids > 0 THEN
FOR asteroid = 1 TO numasteroids

_PUTIMAGE (asteroidx(asteroid), asteroidy(asteroid)), obstacle

IF explosion = 0 THEN 'this is added so that the ship doesn't explode twice (it is invulnerable for a while)

IF shipx + 10 >= asteroidx(asteroid) AND shipx <= asteroidx(asteroid) + 10 THEN
IF shipy + 10 >= asteroidy(asteroid) AND shipy <= asteroidy(asteroid) + 10 THEN


explosion = 1
lives = lives - 1

END IF
END IF

END IF

asteroidx(asteroid) = asteroidx(asteroid) - asteroidspeed(asteroid)



IF asteroidx(asteroid) < 0 - 10 THEN
removeasteroid = asteroid
END IF


NEXT
END IF


IF removeasteroid <> 0 THEN
FOR k = removeasteroid TO numasteroids
asteroidx(k) = asteroidx(k + 1)
asteroidy(k) = asteroidy(k + 1)
asteroidspeed(k) = asteroidspeed(k + 1)
NEXT
numasteroids = numasteroids - 1
removeasteroid = 0
END IF




IF explosion = 1 THEN
expl = expl + 1

FOR k = 1 TO expl
PSET (shipx - INT(RND * k), shipy - INT(RND * k)), INT(RND * 255)
PSET (shipx + INT(RND * k), shipy + INT(RND * k)), INT(RND * 255)
PSET (shipx - INT(RND * k), shipy + INT(RND * k)), INT(RND * 255)
PSET (shipx + INT(RND * k), shipy - INT(RND * k)), INT(RND * 255)
NEXT
IF expl > 30 THEN expl = 0: explosion = 0
END IF


rand = INT(RND * (30 - (collected * 3))) + 1 '(collected*3) makes the asteroids more frequent
IF rand = 1 THEN
numasteroids = numasteroids + 1
asteroidx(numasteroids) = 319 + 10
asteroidy(numasteroids) = INT(RND * 219) + 1
asteroidspeed(numasteroids) = RND * 1.5 + .5 + ((collected + 1) / 50) '(collected+1)/50 makes them faster
END IF



IF heart = 0 THEN 'only if heart is 0 should we create one (it is already created otherwise)
rand = INT(RND * 1000) + 1 'very seldom does a heart arrive
IF rand = 1 THEN
heart = 1
heartx = 319 + 10
hearty = INT(RND * 219) + 1
heartspeed = RND * 1.5 + .5
END IF
END IF

'here we display the heart and handles the collision for the heart:
IF heart = 1 THEN
_PUTIMAGE (heartx, hearty), life
heartx = heartx - heartspeed

IF heartx < -10 THEN heart = 0 'remove it if it goes outside the screen.

IF shipx + 10 >= heartx AND shipx <= heartx + 10 THEN
IF shipy + 10 >= hearty AND shipy <= hearty + 10 THEN
'it collided with the heart!
heart = 0 'set heart to 0 to remove it
lives = lives + 1 'add 1 to lives

END IF
END IF

END IF

'we do the same for the numbers as with the heart:
IF number = 0 THEN
rand = INT(RND * 500) + 1 'very seldom does a number arrive
IF rand = 1 THEN
number = 1
numberx = 319 + 10
numbery = INT(RND * 219) + 1
numberspeed = RND * 1.5 + .5
END IF
END IF

'here we display the number and handle the collision for the number:
IF number = 1 THEN
_PRINTSTRING (numberx, numbery), STR$(collected + 1) 'we use printstring to represent the number
numberx = numberx - numberspeed
IF numberx < -10 THEN number = 0
IF shipx + 10 >= numberx AND shipx <= numberx + 10 THEN
IF shipy + 10 >= numbery AND shipy <= numbery + 10 THEN
'it collided with the number!
collected = collected + 1 'add one to the collected numbers
number = 0 'set number to 0 to remove it
END IF
END IF
END IF



'loose:
IF lives < 0 THEN
LOCATE 10, 15: PRINT "GAME OVER"
_DISPLAY: END
END IF

'win:
IF collected = 9 THEN
LOCATE 10, 16: PRINT "YOU WIN"
_DISPLAY: END
END IF



_DISPLAY
LOOP


And the whole tutorial file is here:
.html   A_Small_Game_Tutorial.html (Size: 52.38 KB / Downloads: 143)

Print this item

  Default Parameters - Quick Question
Posted by: TarotRedhand - 11-12-2023, 12:51 PM - Forum: Help Me! - Replies (6)

The question is quite simply "Does QB64 PE Support Default Parameters for Subs and Functions?". Perhaps it's my age but I can't see anything on the wiki that addresses this. The reason why I ask is that I have written a library in NWScript (a C++ style scripting language for Bioware's/Beamdog's game Neverwinter Nights) that I think could also be useful for QB64 PE if I were to convert it. However, I have made extensive use of default parameters for it. So I need to know, in order to determine if converting this library would be worthwhile.

Thanks.

TR

Print this item

  UDT problems
Posted by: eoredson - 11-12-2023, 05:46 AM - Forum: Help Me! - Replies (31)

Neither of these 2 functions work:

Code: (Select All)
Type BitStruct
  xbit As _Bit
End Type

Dim BitStructure As BitStruct
BitStructure.xbit = 0
Print BitStructure.xbit
Code: (Select All)
type StructType
  Array(10) As Integer
End Type

Dim Structure As StructType
Structure.Array(10) = 10

Print this item

  Need custom sorting algorithm
Posted by: random1 - 11-12-2023, 05:07 AM - Forum: General Discussion - Replies (15)

Hi all

I m looking for a sorting algorithm, see image.
Thanks in advance for your help.

[Image: IMG1.png] 

the sorting algorithm needs to sort the columns that are most similar like shown in the image above.  The image
was made by hand for illustration purposes.  The attached file is just a small sample but the number of columns 
will always be 112.   The idea is to find around 20 to 25 columns with the highest number of matching *'s 

The output only needs to show column numbers,  Example, if 15 columns are found to have 6 *'s in common then 
those 15 columns will be the output,  "5,12,22,35,43,50... n". 

The file I  am processing  often contains 500 or more lines each with 112 columns.  This seems like it would be easy 
enough but once I started the more complicated it got.  Any info would be greatly appreciated.

R1

Sample file, this is a .txt file which on has 25 lines of data.
https://app.box.com/s/38p52cfs6e6bbcbxsuhver7fxeb5dgcs

RSample 
 appreciate

Print this item

  Integer memory storage
Posted by: bobalooie - 11-11-2023, 11:12 PM - Forum: General Discussion - Replies (8)

How does QB64PE handle storage in RAM memory of the various integer data types on a 64-bit machine? Obviously _INTEGER64 is the natural integer size, but I am curious about the smaller integers.

Print this item

  Small full screen editor
Posted by: eoredson - 11-11-2023, 08:00 AM - Forum: Utilities - Replies (13)

Hi,

I am sure full screen editors have been around for awhile but here is another one:

Erik.

Version history:

Code: (Select All)
Initial port to QB64 v1.0a
New v2.0a:
    Adds insert cursor for overstrike in Backspace, Tab, and InsertChar.
    Adds support for 40 column editing and display.
New v3.0a:
    Adds ListFiles and SearchFiles.
New v3.1a:
    Fixes some scrolling in SearchFiles.
New v3.2a:
  Adds Ctrl-C copyfile in SearchFiles.
  Adds Ctrl-D changedrive in SearchFiles.
  Adds OldSkool directory delete in SearchFiles.
New v3.3a:
  Adds F1 help key to ScrnEdit.
  Adds F1 help key to SearchFiles.
New v3.4a:
  Adds _hide to shell in SearchFiles.
  Adds drives to file list in SearchFiles.
  Adds shell to vol to SearchFiles.
New v3.5a:
   Moves F2 display in SearchFiles.
   Adds F4 toggle sort order in SearchFiles.
   Display Drive: and Dir: and File: in Display.Screen in SearchFiles.
New v3.6a:
   Adds DriveList to improve display in Display.Screen in SearchFiles.
   Adds custom FileExists and DirExists functions.
   Adds Ctrl-E MKdir and Ctrl-F refresh to SearchFiles.
New v3.7a:
   Adds buffer to Ctrl-C CopyFile in SearchFiles to improve copying speed.
   Adds F8 to recursively load file in ScrnEdit.
New v3.8a:
   Fixes buffer overrun in CopyFile in SearchFiles.
   Fixes pagedown in Ctrl-End in SearchFiles.
   Fixes error with long filename.
New v4.0a:
   Adds Ctrl-G RenameFile in SearchFiles.
   Adds Ambig$ function to ValidFileChar2$
   Adds file exists ValidFileChar3$ function to ScrnEdit.
New v4.1a:
    Adds Tab and Shift-Tab to SearchFiles.
    Adds Control-Right and Control-Left to SearchFiles.
    Adds Control-Up and Control-Down to SearchFiles.
    Checks Ctrl-D ChangeDrive is in drivelist.
New v4.2a:
    Adds F4 AppendFile and F5 InsertFile to ScrnEdit.
    Fixes array error in InsertFile.
    Adds '-/+', 'a-z', 'A-Z', '0-9' to scan filename in SearchFiles.
    Adds F3 to search filename in SearchFile. And Ctrl-F3 to repeat search.
New v4.3a:
    Adds counters and continuous display to ListFiles.
    Adds FormatString$ output display to ListFiles.
New v4.4a:
    Adds prompt for DirSpec in SearchFiles.
    Adds F4 to sort files and F5 to sort dirs in SearchFiles.
    Adds F6 to recursively call SearchFiles.



Attached Files
.txt   scrnedit.txt (Size: 907 bytes / Downloads: 35)
.bas   SCRNEDIT.BAS (Size: 118.97 KB / Downloads: 49)
Print this item

  Why aren't these subroutines working on user defined types?
Posted by: James D Jarvis - 11-10-2023, 01:30 AM - Forum: Help Me! - Replies (4)

I'm surely missing something somewhere but why aren't the subroutines working on the values in this user defined type?  
Shouldn't incr be increasing the values as it does for the variable A?

Code: (Select All)
Type score_type
    max As Integer
    cur As Integer
End Type

Type player_type
    power As score_type
    speed As score_type
    x As Integer
    y As Integer
End Type

Dim player As player_type

player.power.max = 100
player.power.cur = 0
player.x = 100
player.y = 100

A = 10
incr A, 1
Print A   

incr player.power.cur, 1
Print player.power.cur

incr player.x, 1
Print player.x

Sub incr (n, v)
    n = n + v
End Sub

Sub decr (n, v)
    n = n - v
End Sub

Print this item

  Detect Current Screen Mode?
Posted by: James D Jarvis - 11-07-2023, 10:34 PM - Forum: Help Me! - Replies (2)

Is there a simple means to detect the screen mode being used in a program. I can make my program behave so this is not an issue but I want to make it part of a subroutine I may share with others and just not sure how to do it from within the subroutine alone.

Print this item

  Windows Security does not like this example
Posted by: James D Jarvis - 11-07-2023, 10:21 PM - Forum: General Discussion - Replies (4)

Windows security does not like this example:
_MEM - QB64 Phoenix Edition Wiki

It quarantined QB6PE itself.     Likely related to recent scare someone else had.

Print this item

  Consider becoming a patron
Posted by: TerryRitchie - 11-07-2023, 06:49 PM - Forum: General Discussion - Replies (16)

Over the past year you've probably noticed that new versions of PE, bug fixes, and enhancements are handled very quickly and efficiently by the PE dev team.

All of this excellent service by them, in my opinion, needs some recognition.

Consider becoming a patron of the site. A few bucks a month goes a long way to help paying the bills. With any extra money left over I would love for these guys to be able to treat themselves and loved ones to a steak dinner now and then.

Here is the link to the Patreon discussion: https://qb64phoenix.com/forum/showthread.php?tid=1387

Print this item