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

Username/Email:
  

Password
  





Search Forums

(Advanced Search)

Forum Statistics
» Members: 497
» Latest member: VikRam2025
» Forum threads: 2,849
» Forum posts: 26,677

Full Statistics

Latest Threads
Fun with Ray Casting
Forum: a740g
Last Post: a740g
1 hour ago
» Replies: 10
» Views: 182
Very basic key mapping de...
Forum: SMcNeill
Last Post: a740g
5 hours ago
» Replies: 1
» Views: 39
Who wants to PLAY?
Forum: QBJS, BAM, and Other BASICs
Last Post: grymmjack
6 hours ago
» Replies: 2
» Views: 37
Methods in types
Forum: General Discussion
Last Post: bobalooie
6 hours ago
» Replies: 0
» Views: 24
QBJS - ANSI Draw
Forum: QBJS, BAM, and Other BASICs
Last Post: dbox
Yesterday, 04:09 PM
» Replies: 3
» Views: 91
Cautionary tale of open, ...
Forum: General Discussion
Last Post: doppler
Yesterday, 10:23 AM
» Replies: 3
» Views: 99
Extended KotD #23 and #24...
Forum: Keyword of the Day!
Last Post: SMcNeill
Yesterday, 09:51 AM
» Replies: 0
» Views: 39
Big problem for me.
Forum: General Discussion
Last Post: JRace
Yesterday, 05:11 AM
» Replies: 11
» Views: 195
Virtual Arrays
Forum: Site Suggestions
Last Post: hsiangch_ong
Yesterday, 12:35 AM
» Replies: 8
» Views: 298
QBJS v0.9.0 - Release
Forum: QBJS, BAM, and Other BASICs
Last Post: hsiangch_ong
Yesterday, 12:25 AM
» Replies: 17
» Views: 319

 
  Shadowing
Posted by: MasterGy - 10-21-2022, 06:31 PM - Forum: MasterGy - Replies (15)

Back when I made the "tree house" game, a few years ago. It's 3D and you can only walk around. At that time, I remember Galleon rewrote the program and added something to the display part to shade the textures. Everything got darker in proportion to the distance. I didn't understand then. I looked for the code, but I couldn't find it, and the old forum is not available. Since then, I have solved the distance-proportional darkening of games by generating lots of textures. That's a lot of memory, and it doesn't work on a large surface, because if one vertex of a triangle is close to you and another vertex is far away, then what shade should it get? So it's only good for displaying small textures.

In the past few days, I've been thinking about how Galleon solved the problem of placing a texture of any size on the screen in any way. Then he told me that a black mask with an alpha distance proportional to the texture should be drawn. That's when I understood that by switching _depthbuffer on and off, it can be solved by dragging the alpha texture after each texture. And I understood why I didn't use it then. Very good, fast, practical, only switching the z-buffer on and off slows down the program significantly.

I was wondering how it could be solved without switching on the z-buffer.

Suppose _maptriangle gets a 3d point. be x,y,z. it should be 20,10,30. This point in the plane will be where, for example, 200,100,300 or 2,1,3 or 40,20,60. This simple realization helped. Simply, after drawing the texture, x,y,z must be multiplied by 0.999999, and then the mask can be drawn on it. That way, you don't have to switch on the z-buffer.
I thank Galleon several times already! If it doesn't show it then, I won't think about how it could be operated faster.



[Image: qb-2.jpg]

[Image: qb-1.jpg]


Code: (Select All)
picture$ = "" '<-------- enter an image or leave the field blank



'texture
If _FileExists(picture$) Then
    text = _LoadImage(picture$, 33)
Else
    temp = _NewImage(1, 1, 32): _Dest temp: Cls , _RGB32(255, 255, 255): text = _CopyImage(temp, 33): _FreeImage temp
End If

'window
monx = 800: mony = Int(monx / _DesktopWidth * _DesktopHeight): monm = monx * .008: mon = _NewImage(monx, mony, 32): Screen mon: _FullScreen: _DisplayOrder _Hardware , _Software

Const pip180 = 3.141592 / 180
Dim Shared me(9), cosrotz, sinrotz, cosrotx, sinrotx, sinrot_cs, cosrot_cs

'cube locations, sizes
Randomize Timer
cube_res = 1000: cube_deep = 1000
temp = _NewImage(cube_res - 1, cube_deep - 1, 32): _Dest temp: For t = 0 To cube_res - 1: For t2 = 0 To cube_deep - 1
    PSet (t, t2), _RGBA32(0, 0, 0, Int(255 / (cube_deep - 1) * t2) - 3)
Next t2, t: cube_text = _CopyImage(temp, 33): _FreeImage temp

'mask distance behind texture
Dim shdw_m(15000): For t = 0 To 15000: shdw_m(t) = Interpolate(.999, .97, 1 / 15000 * t): Next t


mapdim = 1000

'make cubes
obj_c = 200
Dim obj(obj_c - 1, 9): _Source deep_text: For t = 0 To obj_c - 2: For t2 = 0 To 2: obj(t, t2) = mapdim * Rnd: obj(t, t2 + 3) = 10 + 40 * Rnd: Next t2, t

For t = 0 To 2: obj(obj_c - 1, 3 + t) = mapdim / 2: obj(obj_c - 1, t) = mapdim / 2: Next t
For t = 0 To 2: me(t) = mapdim / 2: Next t: light = .2: me(4) = -.2: ut_me4 = -.2: ylook_limit = 80 'radian

_Dest mon
Locate 1, 1: Print "moving:WASD       looking:mouse        light adjust : mousewheel"
Dim p(3, 2), p2(3, 2), pc(7, 9)
Do: _Limit 30
    'control
    mouse_sens_xy = .01: mouse_sens_z = .01
    mousex = 0: mousey = 0: mousew = 0: While _MouseInput: mousex = mousex + _MouseMovementX: mousey = mousey + _MouseMovementY: mousew = mousew + _MouseWheel: Wend
    me(3) = me(3) + mousex * mouse_sens_xy: me(4) = me(4) + mousey * mouse_sens_z

    ylook_deg = ((me(4) / pip180) + 90): If Abs(ylook_deg) > ylook_limit Then me(4) = ut_me4 Else ut_me4 = me(4)
    rot_cs = (rot_cs + mousex * .001 * Abs(Sin(me(4)))) * .9
    light = light - mousew * 0.005: If light < 0 Then light = 0 Else If light > 1 Then light = 1
    Locate 2, 1: Print "light:"; Int(light * 100); "%   "
    position_speed = 5
    kw = _KeyDown(119): ks = _KeyDown(115): ka = _KeyDown(97): kd = _KeyDown(100): new_direction = (Abs(ka Or kd Or kw) Or -Abs(ks)) * position_speed
    deg_XY = -90 * Abs(ka) + 90 * Abs(kd): szog_xy = me(3) + deg_XY * pip180: szog_z = me(4)
    me(0) = me(0) - Sin(szog_xy) * (1 - Cos(szog_z)) * new_direction
    me(1) = me(1) - Cos(szog_xy) * (1 - Cos(szog_z)) * new_direction
    me(2) = me(2) - Cos(szog_z + _Pi) * new_direction

    cosrotz = Cos(me(3)): sinrotz = Sin(me(3)): cosrotx = Cos(me(4)): sinrotx = Sin(me(4)): cosrot_cs = Cos(rot_cs): sinrot_cs = Sin(rot_cs) 'to rotating angles

    'draw cubes
    px1 = cube_res / 2: px2 = cube_res - 2
    dl = cube_deep - 3: c_dis = Interpolate(50, 2500, light): temp = cube_deep / c_dis
    For a_obj = 0 To obj_c - 1: For t = 0 To 7
        For t2 = 0 To 2: pc(t, t2) = (obj(a_obj, 3 + t2) * (Sgn(t And 2 ^ t2) * 2 - 1) + (obj(a_obj, t2) - me(t2))): Next t2
            rotate pc(t, 0), pc(t, 1), pc(t, 2)
            pc(t, 3) = Sqr(pc(t, 0) * pc(t, 0) + pc(t, 1) * pc(t, 1) + pc(t, 2) * pc(t, 2))
            sm = shdw_m(Abs(Int(pc(t, 2))))
            For t2 = 0 To 2: pc(t, 4 + t2) = pc(t, t2) * sm: Next t2
        Next t

        For t = 0 To 5: For t2 = 0 To 3: side(t2) = Val(Mid$("024623673175105445670123", 1 + t * 4 + t2, 1)): For t3 = 0 To 2: p(t2, t3) = pc(side(t2), t3): p2(t2, t3) = pc(side(t2), t3 + 4): Next t3, t2

            'texture
            _MapTriangle (0, 0)-(_Width(text) - 1, 0)-(0, _Height(text)), text To(p(0, 0), p(0, 1), p(0, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _Smooth
            _MapTriangle (_Width(text), _Height(text))-(_Width(text) - 1, 0)-(0, _Height(text)), text To(p(3, 0), p(3, 1), p(3, 2))-(p(1, 0), p(1, 1), p(1, 2))-(p(2, 0), p(2, 1), p(2, 2)), , _Smooth

            'shadow mask
            For t2 = 0 To 3: py(t2) = Int(temp * pc(side(t2), 3)): If py(t2) > dl Then py(t2) = dl
            Next t2
            _MapTriangle (1, py(0))-(px1, py(1))-(px2, py(2)), cube_text To(p2(0, 0), p2(0, 1), p2(0, 2))-(p2(1, 0), p2(1, 1), p2(1, 2))-(p2(2, 0), p2(2, 1), p2(2, 2)), , _Smooth
            _MapTriangle (1, py(3))-(px1, py(1))-(px2, py(2)), cube_text To(p2(3, 0), p2(3, 1), p2(3, 2))-(p2(1, 0), p2(1, 1), p2(1, 2))-(p2(2, 0), p2(2, 1), p2(2, 2)), , _Smooth
    Next t, a_obj

    _Display

Loop
Function Interpolate (a, b, x): Interpolate = a + (b - a) * x: End Function
Sub rotate (px, py, pz2): px3 = px * cosrotz - py * sinrotz: py2 = px * sinrotz + py * cosrotz: py3 = py2 * cosrotx - pz2 * sinrotx: pz3 = py2 * sinrotx + pz2 * cosrotx
px4 = px3 * cosrot_cs - py3 * sinrot_cs: py4 = px3 * sinrot_cs + py3 * cosrot_cs: px = -px4: py = -py4: pz2 = -pz3: End Sub

Print this item

  Referencing variables via pointers
Posted by: SMcNeill - 10-21-2022, 03:49 PM - Forum: Works in Progress - Replies (8)

A little proof of concept method for a bigger program that I'm playing around with, which allows us to reference variables by offset rather than by name.

Code: (Select All)
Dim foo As Integer
Dim foo2 As _Unsigned _Byte
Dim foo3 As Long

Print foo, foo2, foo3

ToggleVar _Offset(foo), Len(foo)
ToggleVar _Offset(foo2), Len(foo2)
ToggleVar _Offset(foo3), Len(foo3)

Print foo, foo2, foo3

ToggleVar _Offset(foo), Len(foo)
ToggleVar _Offset(foo2), Len(foo2)
ToggleVar _Offset(foo3), Len(foo3)

Print foo, foo2, foo3

Sub ToggleVar (variable_offset As _Offset, variable_size As _Byte)
    Static m As _MEM
    m = _Mem(variable_offset, variable_size)
    Select Case variable_size
        Case 1
            temp%% = _MemGet(m, m.OFFSET, _Byte)
            _MemPut m, m.OFFSET, Not temp%% As _BYTE
        Case 2
            temp% = _MemGet(m, m.OFFSET, Integer)
            _MemPut m, m.OFFSET, Not temp% As INTEGER
        Case 4
            temp& = _MemGet(m, m.OFFSET, Long)
            _MemPut m, m.OFFSET, Not temp& As LONG
        Case 8
            temp&& = _MemGet(m, m.OFFSET, _Integer64)
            _MemPut m, m.OFFSET, Not temp&& As _INTEGER64
    End Select
End Sub

Take a moment and be certain to notice that these are 3 different type variables all being processed and altered via the same SUB. Smile

Print this item

  Drop Down Menu
Posted by: Dimster - 10-21-2022, 03:29 PM - Forum: Help Me! - Replies (7)

Here is a bare bones of a drop down menu which I have been using. I have had to use a Slowing value to smooth out the speed at which the drop down occurs. I was wondering if there might be a better way to control the speed.

Cls
Screen _NewImage(1200, 900, 32)
Dim Shared DarkGreen&
Dim Shared Yellow&
Dim Shared Pink&
DarkGreen& = _RGB32(0, 129, 0)
Yellow& = _RGB(255, 255, 0)
Pink& = _RGB(216, 50, 166)


'Large background box
Line (0, 0)-(1199, 50), Pink&, BF
Sleep
c1 = 7
r1 = 7
c2 = 126
r2 = 46
'The 5 smaller box
Line (c1, r1)-(c2, r2), DarkGreen&, BF

r1 = 51
r2 = 93
'The Drop Down
For DDwn = 1 To 25
    Color Yellow&
    _PrintString (12, 15), "Opening Info"
    Line (c1, r1)-(c2, r2), DarkGreen&, BF
    For slow = 1 To 10000000: Next
    r1 = r1 + DDwn
    r2 = r2 + DDwn
Next
Sleep

Print this item

  Set Of More DOS Utilities
Posted by: eoredson - 10-20-2022, 11:58 PM - Forum: Utilities - No Replies

Find attached a file called the set of more dos utilities..

First, this is not QB64. Instead it is QB45/QB71/VBdos..

Next, you get what you see. Some utilities work. Some do not.

There is an imbedded \examples directory with 50 sample files.

Erik.

The packing list is:

Code: (Select All)
More public domain Dos utilities v72.0a packing list:

Runtime files:

  Filters: (delete any old TEE*.COM first)..

  TEE.EXE      --  Piping redirection program
    (sends tee stdin to screen/file)
  TEE2.EXE      --  Piping redirection program
    (sends tee stdin to screen/printer/file)
  TEE3.EXE      --  Piping redirection program
    (sends tee stdin to screen/printer/aux/file)

  PD Swap Utility:

  SHROOM.COM    --  Program swapping utility
  SHROOM.DOC    --  Program documentation
  SHROOM.TXT    --  Program text info

  More DOS Utilities (streaming pipe programs):

  FINDY.EXE    --  Pipe find utility
    (sends piped searched stdin to output)
  ZSORT.EXE    --  Pipe sort utility
    (sends piped sorted stdin to output)

  More DOS Utilities (streaming):

  DELDIR.EXE    --  Directory delete utility
  DELETE.EXE    --  File delete utility
  DIRATTR.EXE  --  File/directory attribute display utility
  DIRS.EXE      --  Directory display utility
  DRIVES.EXE    --  Drive display utility
  LISTVOLS.EXE  --  Volume display utility
  MAKDIR.EXE    --  Directory make utility
  MKSERIAL.EXE  --  Volume serial change utility
  MKVOLBPB.EXE  --  Volume bpb update utility
  NAMEIT.EXE    --  File rename utility
  NEWDIR.EXE    --  Directory change utility
  NEWNAME.EXE  --  Dos 8.3 file rename utility
  NEWVOL.EXE    --  Volume update utility
  PARSE.EXE    --  Stdin parse example utility
  RDSERIAL.EXE  --  Volume serial display utility
  RDVOLUME.EXE  --  Volume findfirst label display utility
  READDLL2.EXE  --  .dll file description utility
  READQLB.EXE  --  .qlb file description utility
  RENDIR.EXE    --  Directory rename utility
  RENVOL.EXE    --  Volume rename utility
  SETATTR.EXE  --  File/directory attribute change utility
  TOUCH.EXE    --  File update utility
  TOUCHDIR.EXE  --  Directory update utility
  TOUCHVOL.EXE  --  Volume update utility
  TREEDEL.EXE  --  Directory delete utility
  TYPEA.EXE    --  ANSI file content display utility
  TYPEY.EXE    --  File content display utility
  WHEREIS.EXE  --  File search utility
  XCOUNT.EXE    --  Directory/file count utility
  XDIR.EXE      --  File display utility
  XTREE.EXE    --  Directory sort utility
  ZIPLOOK.EXE  --  Zip file description utility

  More DOS Utilities (non-streaming):

  ASCII.EXE    --  Ascii chart maker
  BIOS.EXE      --  Reads bios list using inline assembly
  CLOCK1.EXE    --  Display current date\time in window.
  COUNT.EXE    --  Counts files/lines/bytes of code
  DISKCOMP.EXE  --  Compares diskettes in drive A:
  DISKCOPY.EXE  --  Copies diskette from A: to A:
  FILECOMP.EXE  --  Compares byte values of two files
  FINDCODE.EXE  --  Program to locate SUB statements
  FINDDOC.EXE  --  Program to locate keywords
  FINDVAR.EXE  --  Program to locate variables
    FIND.DOC      --  Documentation for find utilities
  HEXCALC.EXE  --  Hex-to-Dec calculator
  HEXLIST.EXE  --  Hex chart maker
  LOWERDTR.EXE  --  Modem port utility
  MACHINE.EXE  --  Local workstation name display utility
  RAISEDTR.EXE  --  Modem port utility
  RUNPROG.EXE  --  Starts command line programs
  SCRNSAVE.EXE  --  Starts Windows screen saver
  SERIAL.BAS    --  Creates a serial number from date/time
  UNINSTAL.EXE  --  Generic uninstal utility for DOS
    SAMPLE.CFG    --  Uninstal config file
  WHATIS.EXE    --  Expression parser
    TROOLEAN.DOC  --  Extended boolean charts

  Windows utilities:

  LIB.EXE      --  Library program to create and edit .lib files
  MEM.EXE      --  Displays various DOS memory settings
  NMAKE.EXE    --  Compiles programs based on makefile instructions
  START.EXE    --  Windows utility to launch programs

  Misc. files:

  AUTHOR.BAT    --  Author information program
  AUTHOR.TXT    --  Author information file
  BIOS.TXT      --  BIOS equipment list
  BREAK.TXT    --  Notes on DOS break flag
  COHESION.TXT  --  Info for utility usage
  COMPILE.LST  --  Compiler switches list
  COMPILE.TXT  --  Instructions on compiling
  CTRL.TXT      --  Short note on Control-Break
  DATETIME.TXT  --  Further date\time explanations
  ERROR.TXT    --  List of DOS error codes
  EXAMPLE?.BAT  --  Examples using utilities
  PSPTRICK.TXT  --  Text on file handles
  SERIAL.TXT    --  Info on disk serial number
  UPGRADE1.TXT  --  Latest upgrade notes
  UPGRADE2.TXT  --  Old upgrade notes
  US.TXT        --  U.S. Constitution
  VERSION.LST  --  Most recent upgrade notes

  Misc. list files:

  ASCII.TXT    --  Text file of ascii codes
    ASCII1.TXT    --  Ascii codes 0 to 127
    ASCII2.TXT    --  Ascii codes 128 to 255
  HEX.TXT      --  Text file of hex codes
    HEX1.TXT      --  Hex codes 0 to 127
    HEX2.TXT      --  Hex codes 128 to 255

  Misc. readme list files:

  README.COM    --  Readme program for readme.txt
    README.TXT    --  Description of utilities
  READIT2.COM  --  Readme program for disclaim.doc

  Misc. utilities:

  DOBREAK.BAT  --  Example to check DOS break flag state
  CHECKBRK.COM  --  Returns Errorlevel of break flag
  CLEARBRK.COM  --  Clears break flag in DOS
  COUNTBRK.COM  --  Displays actual value of break flag
  SETBRK.COM    --  Sets break flag in DOS
  ZIPCHECK.BAT  --  Batch program to check .zip files
    BADCHECK.DAT  --  Used by Zipcheck.bat
    ZIPCHECK.DAT  --  Used by Zipcheck.bat

  Misc. imbedded file source:

  \Examples\*.Zip  --  Over 50 examples in BASIC programming.

  \Copyit55\*.Zip  --  File copy utility.
  \Hexxit86\*.Zip  --  Hex editor utility.
  \Stree32\*.Zip    --  Directory display utility.
  \Whatis40\*.Zip  --  Whatis expression parser.

Source files:

  BC7.INC      --  Backward compatible file for BC7 (PDS v7.10) compiling
  BC71.INC      --  Backward compatible file for BC7 (PDS v7.10) compiling

  WHATIS.INC    --  Include file for Whatis

  ERROR.BAS    --  Error function source for VB
  ERROR.LIB    --  Error function library for VB
  ERROR2.BAS    --  Error function source for QB
  ERROR2.LIB    --  Error function library for QB

  *.BAS        --  Program sources
  *.BI          --  Source headers

  MAKEALL.BAT  --  Makes all programs.
  LINKALL.BAT  --  Links all programs.

  MAKEFILE      --  Compiler directives for NMAKE.EXE with VB Pro v1.00
  MAKEFILE.NMK  --  Compiler directives for NMAKE.EXE with VB Pro v1.00
  MAKEFILE.BC7  --  Compiler directives for making with BC7 (PDS v7.10)
  MAKEZIP.BAT  --  Makes Ziplook.exe w/ BC7 (PDS v7.10)
  NOEDIT.OBJ    --  Line input editing stub file
  KEYTRAP.ASM  --  Assembly program to trap Control-Break
  KEYTRAP.OBJ  --  Precompiled source to Keytrap.asm
  SWAPBAS.ASM  --  Source to Runprog.exe swapper
  SWAPBAS.OBJ  --  Precompiled Runprog.exe swapper
  ZIPVIEW.ASM  --  Source to .zip viewing
  ZIPVIEW.OBJ  --  Precompiled .zip viewing source

Auxiliary files:

  *.ASI        --  ASIC v5.00 program source
  *.BAT        --  Batch programs
  *.DOC        --  Documentation files
  *.PRJ        --  ASIC v5.00 project files
  *.LST        --  List files
  *.TXT        --  Text files

Temporary files:

  *.BAK        --  Text editor backup files
  *.MAP        --  Linker map files
  *.OBJ        --  Compiler object files

Required compiling files for VB Pro v1.00:

  BC.EXE        --  The VB Pro v1.00 compiler
  LINK.EXE      --  Most recent Linker
  VBDOS.LIB    --  VB Pro v1.00 interrupt assembly library
  VBDCL10E.LIB  --  VB Pro v1.00 standalone library
  VBDRT10E.LIB  --  VB Pro v1.00 runtime library
  VBDRT10E.EXE  --  VB Pro v1.00 runtime module

Required compiling files for Ziplook.exe or for BC7 (PDS v7.10) compiling:

  BC.EXE        --  The BC v7.10 compiler
  LINK.EXE      --  Most recent Linker
  DTFMTER.LIB  --  BC v7.10 date/time format library
  QBX.LIB      --  BC v7.10 interrupt assembly ibrary
  BCL71EFR.LIB  --  BC v7.10 standalone library
  BCL71ENR.LIB  -  BC v7.10 standalone library
  BRT71EFR.LIB  --  BC v7.10 runtime library
  BRT71EFR.EXE  --  BC v7.10 runtime module

Required compiling files for assembly source:

  TASM.EXE      --  Turbo assembler 4.0, or any later MASM compilers

Filegate project files:

  FILE_ID.DIZ  --  Standard distribution text file

These programs and source are hereby placed into the public domain 2014.

The Author respects the Authors of included PD/Shareware programs.

-end-



Attached Files
.zip   MORUTL72.ZIP (Size: 4.33 MB / Downloads: 18)
Print this item

  Fun with hardware acceleration.
Posted by: Pete - 10-20-2022, 10:25 PM - Forum: General Discussion - No Replies

One nice effect is you can have 2 font sizes/styles in the same program. Here is a flow-through example with a large and small lucon font.

Code: (Select All)
$COLOR:32
DIM SHARED overlay, ii
f1 = 22 ' Sets font size to 22 and calculates the max screen height and width for your desktop.
h = (_DESKTOPHEIGHT - 60) \ f1
w = _DESKTOPWIDTH \ (f1 / 1.66)
WIDTH w, h
_SCREENMOVE 0, 0
fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
font& = _LOADFONT(fontpath$, f1 - 2, "monospace") ' - 2 to shorten the screen height just a bit.
_FONT font&
_DELAY .25
swtch = 1

DO
    _LIMIT 30
    SELECT CASE swtch
        CASE 1
            CALL prog1
            IF INKEY$ = CHR$(27) THEN SYSTEM
        CASE -1
            CALL prog2
    END SELECT

    swtch = swtch * -1
LOOP

SUB prog1
    ii = ii + 1
    IF i > 300 THEN END ' Safety in case of memory leak.
    IF ABS(TIMER - z1) > .5 THEN LOCATE 2, 2: PRINT LTRIM$(STR$(ii)); "  ";
END SUB

SUB prog2
    STATIC target$, z2, bxx!
    hardware_top = 34
    bxy! = hardware_top

    overlay = _NEWIMAGE(_WIDTH * _FONTWIDTH, _HEIGHT * _FONTHEIGHT, 32)

    _DEST overlay

    font& = _LOADFONT("lucon.ttf", 12, "monospace")
    _FONT font&

    SELECT CASE target$
        CASE ""
            bxx! = RND * 80 + 5
            target$ = "on"
            z2 = TIMER
        CASE "on"
            COLOR Yellow, 0
            t$ = " " + CHR$(218) + STRING$(11, CHR$(196)) + CHR$(191) + " "
            PSL bxy!, bxx! - 1, t$
            FOR i = 1 TO 2
                t$ = " " + CHR$(179) + STRING$(11, CHR$(32)) + CHR$(179) + " "
                PSL bxy! + i, bxx! - 1, t$
            NEXT
            t$ = " " + CHR$(192) + STRING$(11, CHR$(196)) + CHR$(217) + " "
            PSL bxy! + i, bxx! - 1, t$
            t$ = LTRIM$(STR$(ii))
            PSL bxy! + 1.5, bxx! + 7.5 - LEN(LTRIM$(STR$(ii))) \ 2 - 1, t$
            IF ABS(z2 - TIMER) > 4 THEN
                z2 = TIMER
                target$ = "wait"
            ELSE
            END IF
        CASE "wait"
            IF ABS(z2 - TIMER) > 2 THEN
                z2 = TIMER
                target$ = ""
            END IF
    END SELECT

    _DISPLAY
    _FREEIMAGE overlay
    _DEST 0
END SUB

SUB PSL (y!, x, t$)
    _PRINTSTRING ((x - 1) * _FONTWIDTH, (y! - 1) * _FONTHEIGHT), t$
    Overlay_Hardware = _COPYIMAGE(overlay, 33)
    _PUTIMAGE (0, 0), Overlay_Hardware
    _FREEIMAGE Overlay_Hardware
END SUB

It's more fun and versatile than the old way of using PCOPY, because the screen properties like font size can be separated.

Pete

Print this item

  DEMO ZAPPER- early use of Inform
Posted by: James D Jarvis - 10-20-2022, 03:03 PM - Forum: Programs - No Replies

I saw a couple posts on inform recently so I dug this out.
It's one of my first attempts at using qb64 and Inform from several months ago during the before times.   It's pretty crude and not remotely amazing but nonetheless semi-functional  and shows how I tried to make use of Inform.

DemoZapper

Code: (Select All)
'Demo Zapper
'just fiddling with inform a several months back and whipped this up while still rediscovering QB64
'it's crude, I've gotten a little better witrh qb64 since I did this,  but someone may find it useful as a samplen to figure out inform
'one "alien" and one cannon/ship
'
'  you are going to need the form (which is posted alogn with this) and you are going to need inform installed to make use of this.
'
'
'
': This program uses
': InForm - GUI library for QB64 - v1.3
': Fellippe Heitor, 2016-2021 - fellippe@qb64.org - @fellippeheitor
': https://github.com/FellippeHeitor/InForm
'-----------------------------------------------------------

': Controls' IDs: ------------------------------------------------------------------
Dim Shared DEMOZAPPER As Long
Dim Shared DEMOZAPPERPX As Long
Dim Shared BT2 As Long
Dim Shared BT As Long
Dim Shared FIREBT As Long
Dim Shared MessageBoxTB As Long
Dim Shared SCORELB As Long
Dim Shared ScoreT As Long
Dim Shared POWERLB As Long
Dim Shared ScoreT2 As Long
Dim Shared HULLLB As Long
Dim Shared ScoreT3 As Long

Dim Shared gamescore As Long
Dim Shared power As Long
Dim Shared hull As Long
Dim Shared shipx As Long
Dim Shared shipY As Long

Dim Shared shipshape$, alienshape$, zapshape$
Dim Shared ax, ay, zx(10), zy(10) As Long
Dim Shared shot, allshots
Dim Shared ASPEED
Dim Shared mess$(5)

mess$(1) = "My Totally lame shooter demo"
mess$(2) = "Take Careful Aim"
mess$(3) = "only one alien for now"
mess$(4) = "Power drain does nothing...yet"
mess$(5) = "Hmmm...."
Randomize Timer

': External modules: ---------------------------------------------------------------
'$INCLUDE:'InForm\InForm.bi'
'$INCLUDE:'InForm\xp.uitheme'
'$INCLUDE:'demozapper.frm'

': Event procedures: ---------------------------------------------------------------
Sub __UI_BeforeInit

End Sub

Sub __UI_OnLoad
    'here's where I initialize my part of the program.
    gamescore = 0
    power = 1000
    hull = 100
    shipx = 256
    shipY = 240
    shot = 0
    allshots = 0
    shipshape$ = "R4D8F6D8H6U4L4D4G6U8E6U8"
    alienshape$ = "R8F6G3H3G3H3E6"
    zapshape$ = "R4D6L4U6"
    ax = 30
    ay = 30
    zx = -1
    zy = -1
    ASPEED = 1
    Caption(MessageBoxTB) = " "
End Sub

Sub __UI_BeforeUpdateDisplay
    'This event occurs at approximately 60 frames per second.
    'You can change the update frequency by calling SetFrameRate DesiredRate%

    ' this looked like a good spot in what is effectively the main event loop to pur most of the program.
    Caption(ScoreT) = Str$(gamescore)
    Caption(ScoreT2) = Str$(power)
    Caption(ScoreT3) = Str$(hull)
    mm = Int(Rnd * 500) + 1
    If mm < 6 Then Caption(MessageBoxTB) = mess$(mm)

    'drawship
    _Dest Control(Canvas).HelperCanvas
    k = _RGB(111, 200, 200)
    BeginDraw DEMOZAPPERPX
    Cls , _RGB32(0, 0, 50)
    PSet (shipx, shipY), k
    Draw shipshape$
    If ax > 0 Then
        PSet (ax, ay), k
        Draw alienshape$
    End If
    If shot > 0 Then
        For z = 1 To shot
            If zx(z) > 0 Then
                k = _RGB(200, 20, 20)
                PSet (zx(z), zy(z)), k
                Draw zapshape$
                If Int(zx(z) / 8) = Int((ax + 2.5) / 8) And Int(zy(z) / 8) = Int(ay / 8) Then
                    Beep
                    ax = -1
                    ay = -1
                    gamescore = gamescore + 100
                    zx(z) = -1
                    zy(z) = -1
                End If
            End If
        Next z
    End If
    EndDraw DEMOZAPPERPX
    'move game elements
    If ax < 500 Then
        ax = ax + ASPEED
    Else
        ax = -10
        ay = Int(Rnd * 20) + 20
    End If
    If shot > 0 Then
        For z = 1 To shot
            If zy(z) > 0 Then
                zy(z) = zy(z) - 4
            Else
                zx(z) = -1
                zy(z) = -1
            End If
        Next z
        If zy(shot) = -1 And shot = 10 Then shot = 0
    End If
End Sub

Sub __UI_BeforeUnload
    'If you set __UI_UnloadSignal = False here you can
    'cancel the user's request to close.

End Sub


Sub __UI_Click (id As Long)
    Select Case id
        Case DEMOZAPPER

        Case DEMOZAPPERPX

        Case BT2
            shipx = shipx - 4
        Case BT
            shipx = shipx + 4

        Case FIREBT
            'if the fire button is pressed do this!
            If power > 0 And shot < 10 Then
                shot = shot + 1
                zx(shot) = shipx
                zy(shot) = shipY - 8
                power = power - 1

            End If

        Case MessageBoxTB

        Case SCORELB

        Case ScoreT

        Case POWERLB

        Case ScoreT2

        Case HULLLB

        Case ScoreT3

    End Select
End Sub

Sub __UI_MouseEnter (id As Long)
    Select Case id
        Case DEMOZAPPER

        Case DEMOZAPPERPX

        Case BT2

        Case BT

        Case FIREBT

        Case MessageBoxTB

        Case SCORELB

        Case ScoreT

        Case POWERLB

        Case ScoreT2

        Case HULLLB

        Case ScoreT3

    End Select
End Sub

Sub __UI_MouseLeave (id As Long)
    Select Case id
        Case DEMOZAPPER

        Case DEMOZAPPERPX

        Case BT2

        Case BT

        Case FIREBT

        Case MessageBoxTB

        Case SCORELB

        Case ScoreT

        Case POWERLB

        Case ScoreT2

        Case HULLLB

        Case ScoreT3

    End Select
End Sub

Sub __UI_FocusIn (id As Long)
    Select Case id
        Case BT2

        Case BT

        Case FIREBT

        Case MessageBoxTB

    End Select
End Sub

Sub __UI_FocusOut (id As Long)
    'This event occurs right before a control loses focus.
    'To prevent a control from losing focus, set __UI_KeepFocus = True below.
    Select Case id
        Case BT2

        Case BT

        Case FIREBT

        Case MessageBoxTB

    End Select
End Sub

Sub __UI_MouseDown (id As Long)
    Select Case id
        Case DEMOZAPPER

        Case DEMOZAPPERPX

        Case BT2
            'go that way
            shipx = shipx - 1
        Case BT
            'go this way
            shipx = shipx + 1
        Case FIREBT

        Case MessageBoxTB

        Case SCORELB

        Case ScoreT

        Case POWERLB

        Case ScoreT2

        Case HULLLB

        Case ScoreT3

    End Select
End Sub

Sub __UI_MouseUp (id As Long)
    Select Case id
        Case DEMOZAPPER

        Case DEMOZAPPERPX

        Case BT2

        Case BT

        Case FIREBT

        Case MessageBoxTB

        Case SCORELB

        Case ScoreT

        Case POWERLB

        Case ScoreT2

        Case HULLLB

        Case ScoreT3

    End Select
End Sub

Sub __UI_KeyPress (id As Long)
    'When this event is fired, __UI_KeyHit will contain the code of the key hit.
    'You can change it and even cancel it by making it = 0
    Select Case id
        Case BT2

        Case BT

        Case FIREBT

        Case MessageBoxTB

    End Select
End Sub

Sub __UI_TextChanged (id As Long)
    Select Case id
        Case MessageBoxTB

    End Select
End Sub

Sub __UI_ValueChanged (id As Long)
    Select Case id
    End Select
End Sub

Sub __UI_FormResized

End Sub

'$INCLUDE:'InForm\InForm.ui'


and the form so that works. 

Code: (Select All)
': This form was generated by
': InForm - GUI library for QB64 - v1.3
': Fellippe Heitor, 2016-2021 - fellippe@qb64.org - @fellippeheitor
': https://github.com/FellippeHeitor/InForm
'-----------------------------------------------------------
Sub __UI_LoadForm

    Dim __UI_NewID As Long, __UI_RegisterResult As Long

    __UI_NewID = __UI_NewControl(__UI_Type_Form, "DEMOZAPPER", 889, 494, 0, 0, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "DEMO ZAPPER"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 12)
    Control(__UI_NewID).HasBorder = False

    __UI_NewID = __UI_NewControl(__UI_Type_PictureBox, "DEMOZAPPERPX", 520, 320, 31, 26, 0)
    __UI_RegisterResult = 0
    Control(__UI_NewID).Stretch = True
    Control(__UI_NewID).HasBorder = True
    Control(__UI_NewID).Align = __UI_Center
    Control(__UI_NewID).VAlign = __UI_Middle
    Control(__UI_NewID).BorderSize = 1

    __UI_NewID = __UI_NewControl(__UI_Type_Button, "BT2", 80, 40, 605, 332, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "<"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 24)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).CanHaveFocus = True

    __UI_NewID = __UI_NewControl(__UI_Type_Button, "BT", 80, 38, 715, 332, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, ">"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 24)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).CanHaveFocus = True

    __UI_NewID = __UI_NewControl(__UI_Type_Button, "FIREBT", 190, 49, 605, 392, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "FIRE !"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 18)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).CanHaveFocus = True

    __UI_NewID = __UI_NewControl(__UI_Type_TextBox, "MessageBoxTB", 520, 85, 31, 374, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "Message Box"
    Control(__UI_NewID).HasBorder = True
    Control(__UI_NewID).CanHaveFocus = True
    Control(__UI_NewID).BorderSize = 1

    __UI_NewID = __UI_NewControl(__UI_Type_Label, "SCORELB", 150, 29, 592, 15, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "SCORE"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 18)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).VAlign = __UI_Middle

    __UI_NewID = __UI_NewControl(__UI_Type_Label, "ScoreT", 237, 37, 592, 49, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "0"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 18)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).Align = __UI_Right
    Control(__UI_NewID).VAlign = __UI_Middle

    __UI_NewID = __UI_NewControl(__UI_Type_Label, "POWERLB", 150, 29, 592, 91, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "POWER"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 18)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).VAlign = __UI_Middle

    __UI_NewID = __UI_NewControl(__UI_Type_Label, "ScoreT2", 227, 37, 605, 125, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "0"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 18)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).Align = __UI_Right
    Control(__UI_NewID).VAlign = __UI_Middle

    __UI_NewID = __UI_NewControl(__UI_Type_Label, "HULLLB", 150, 29, 592, 179, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "HULL"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 18)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).VAlign = __UI_Middle

    __UI_NewID = __UI_NewControl(__UI_Type_Label, "ScoreT3", 224, 37, 605, 223, 0)
    __UI_RegisterResult = 0
    SetCaption __UI_NewID, "0"
    Control(__UI_NewID).Font = SetFont("segoeui.ttf", 18)
    Control(__UI_NewID).HasBorder = False
    Control(__UI_NewID).Align = __UI_Right
    Control(__UI_NewID).VAlign = __UI_Middle

END SUB

SUB __UI_AssignIDs
    DEMOZAPPER = __UI_GetID("DEMOZAPPER")
    DEMOZAPPERPX = __UI_GetID("DEMOZAPPERPX")
    BT2 = __UI_GetID("BT2")
    BT = __UI_GetID("BT")
    FIREBT = __UI_GetID("FIREBT")
    MessageBoxTB = __UI_GetID("MessageBoxTB")
    SCORELB = __UI_GetID("SCORELB")
    ScoreT = __UI_GetID("ScoreT")
    POWERLB = __UI_GetID("POWERLB")
    ScoreT2 = __UI_GetID("ScoreT2")
    HULLLB = __UI_GetID("HULLLB")
    ScoreT3 = __UI_GetID("ScoreT3")
END SUB

Print this item

  New Music Player in the works? (Maybe)
Posted by: SpriggsySpriggs - 10-20-2022, 02:36 AM - Forum: Works in Progress - Replies (2)

Even though they've had FLAC in QB64pe for a while I'm just now getting into it. Which is weird because I love FLAC files. The majority of my music library is FLAC format because I'm a big audiophile. Anyways, I decided to look into the FLAC format for tags and such as well as the embedded album art stuff. Turns out, super easy to grab data from a FLAC file. Here's the test code I've used:

Code: (Select All)
Option Explicit
$NoPrefix
$Console

Dim As String file: file = "07 - Project 86 - Team Black.flac"

Dim As Long hfile: hfile = FreeFile
Open "B", hfile, file
Dim As String rawdata: rawdata = Space$(LOF(hfile))
Get hfile, , rawdata
Close

Dim As String SOI: SOI = Chr$(&HFF) + Chr$(&HD8)
Dim As String EOI: EOI = Chr$(&HFF) + Chr$(&HD9)

Dim As String lyrics: lyrics = Mid$(rawdata, InStr(rawdata, "LYRICS=") + Len("LYRICS=")): lyrics = Mid$(lyrics, 1, InStr(lyrics, Chr$(0)) - 2)
Dim As Long tracknumber: Dim As String track: track = Mid$(rawdata, InStr(rawdata, "TRACKNUMBER=") + Len("TRACKNUMBER=")): track = Mid$(track, 1, InStr(track, Chr$(0))): tracknumber = Val(track)
Dim As String songtitle: songtitle = Mid$(rawdata, InStr(rawdata, "TITLE=") + Len("TITLE=")): songtitle = Mid$(songtitle, 1, InStr(songtitle, Chr$(0)) - 2)
Dim As String albumtitle: albumtitle = Mid$(rawdata, InStr(rawdata, "ALBUM=") + Len("ALBUM=")): albumtitle = Mid$(albumtitle, 1, InStr(albumtitle, Chr$(0)) - 2)
Dim As String artist: artist = Mid$(rawdata, InStr(rawdata, "ARTIST=") + Len("ARTIST=")): artist = Mid$(artist, 1, InStr(artist, Chr$(0)) - 2)
Dim As String albumdate: albumdate = Mid$(rawdata, InStr(rawdata, "DATE=") + Len("DATE=")): albumdate = Mid$(albumdate, 1, InStr(albumdate, Chr$(6)) - 1)

Dim As String image: image = Mid$(rawdata, InStr(rawdata, SOI)): image = Mid$(image, 1, InStr(image, EOI) + Len(EOI))
If Len(image) > 0 Then
    Dim As Long hpic: hpic = FreeFile
    If FileExists("cover.jpg") Then Kill "cover.jpg"
    Open "B", hpic, "cover.jpg"
    Put hpic, , image
    Close
    Dim As Long i: i = LoadImage("cover.jpg", 32)
    If i < -1 Then Screen i Else Beep
    rawdata = ""
    Echo lyrics
    Print "Artist:", artist
    Print "Album :", albumtitle
    Print "Track :", tracknumber
    Print "Title :", songtitle
    Print "Date  :", albumdate
    Title artist + " - " + songtitle
    ConsoleTitle Title$ + " lyrics"
    Dim As Long snd: snd = SndOpen(file, "stream")
    If snd Then SndPlay snd
End If

And a test video:


I hope to make me a new project with the code. Obviously a point-and-click GUI. Probably Win32. I will have a trackbar for changing song position as well as a popup window for the lyrics and such. If I get really ambitious then I'll see about making me a tag editor for FLAC/MP3/WAV/etc files.
To download the song for testing: Project 86 - Team Black

Print this item

  Default Command Line Experience in Windows is Now Windows Terminal
Posted by: hanness - 10-19-2022, 12:35 AM - Forum: General Discussion - Replies (21)

As of today, with Windows 11 22H2 October 18th Moment 1 Update, Windows Terminal is now the default command line experience.

In view of this, are there any plans to update QB64PE to better support Windows Terminal for apps that output to the console.

I brought up this question probably about two years ago since we knew back then already that this day was coming, and now it's here.

Print this item

  Calculating the High and Low of it all
Posted by: Dimster - 10-18-2022, 06:44 PM - Forum: Help Me! - Replies (15)

So, I have a massive data base of decimal value with 5 digits after the decimal. I have routine which is trying to find the highest and the lowest of these values. Here is the algorythm that I am using but for some reason it's giving me the Highest value as the Lowest and the Lowest as the Highest. 

        HL = DataBaseValue
        If HL < 1 And HL < Low Then Low = HL
        Low = (_Round(Low * 100000)) / 100000
        If HL < 1 And HL > High Then High = HL 

        High = (_Round(High * 100000)) / 100000

The rounding is to avoid scientific notation and be sure result will be 5 digit decimal value.

I can't see why this algorythm would give the High as Low and the Low as High.

Print this item

Sad Inter-Program Data Sharing
Posted by: Ikerkaz - 10-18-2022, 02:37 PM - Forum: Help Me! - Replies (6)

Hi to all!!!

I am making a space shooter game, and my idea is to make it online for playing with friends... but I have a very big problem, I don't know how to communicate one pc to another Sad

I tried with the Inter-Program Data Sharing Demo (the example listed on the Wiki):
Inter-Program Data Sharing Demo - QB64 Phoenix Edition Wiki

I changed the line "TCP/IP:1234:localhost" and tried everything... my last one was "TCP/IP:8080:xxx.yyy.zzz.nnn" (where xxx.yyy.zzz.nnn is my current IP), but it is useless.

Any ideas? 

Both PCs are NOT in the same LAN, one is mine and the other is from a work colleague.

Thank you very much Smile

Print this item