Posts: 89
Threads: 13
Joined: Apr 2022
Reputation:
9
(02-18-2026, 06:42 PM)bplus Wrote: Code: (Select All) Head(a,b).face = _NEWIMAGE(64, ix, 32)
looks like an attempt to use an UDT array, which as we know can't be done with QB64.
Now I'm confused, the array is just a simple 2-dimensional array of a UDT, not an array declared inside the TYPE definition. The wiki says:
TYPE definitions cannot contain Array variables! Arrays can be DIMensioned as a TYPE definition.
Code: (Select All)
TYPE sigface
x AS INTEGER 'coords of upper left corner of top section
y AS INTEGER
dir AS INTEGER 'orientation direction
num AS INTEGER 'number of sections
style AS INTEGER 'straight or cluster
face AS LONG 'handle to the face image
'for the next two variables, the digits refer to an index into the Sections array
sections AS STRING 'string of digits storing the section image indexes
lit AS STRING 'string of digits storing which sections are lit and which are not
END TYPE
DIM SHARED AS sigface Heads(4,4)
It's not the having, it's the doing.
Posts: 4,695
Threads: 222
Joined: Apr 2022
Reputation:
322
02-18-2026, 08:40 PM
(This post was last modified: 02-18-2026, 08:52 PM by bplus.)
Yeah Ok sorry maybe I am the one confused.
Update: BUT it still works for me! @bobalooie
Code: (Select All) Option _Explicit
Type object
As Long img, wide, high
End Type
Screen _NewImage(800, 600, 32): _ScreenMove 280, 60
Dim I
For I = 1 To 100
Line (Rnd * _Width, Rnd * _Height)-(Rnd * _Width, Rnd * _Height), _RGB32(Rnd * 255), BF
Next
Sleep
Dim test(4, 4) As object, A, B
A = 1: B = 2
testNewImage test(), A, B
Print test(A, B).img, test(A, B).wide, test(A, B).high
Sub testNewImage (outputObj() As object, A, B)
Dim SCR&
SCR& = _ScreenImage
outputObj(A, B).wide = _Width(SCR&) / 2
outputObj(A, B).high = _Height(SCR&) / 2
outputObj(A, B).img = _NewImage(outputObj(A, B).wide, outputObj(A, B).high, 32)
_PutImage , SCR&, outputObj(A, B).img, (0, 0)-(outputObj(A, B).wide - 1, outputObj(A, B).high - 1)
Cls
_PutImage , outputObj(A, B).img, 0
End Sub
724 855 599 923 575 468 400 206 147 564 878 823 652 556 bxor cross forever
Posts: 89
Threads: 13
Joined: Apr 2022
Reputation:
9
02-18-2026, 10:38 PM
(This post was last modified: 02-18-2026, 10:40 PM by bobalooie.)
(02-18-2026, 08:40 PM)bplus Wrote: Yeah Ok sorry maybe I am the one confused.
Update: BUT it still works for me! @bobalooie
Code: (Select All) Option _Explicit
Type object
As Long img, wide, high
End Type
Screen _NewImage(800, 600, 32): _ScreenMove 280, 60
Dim I
For I = 1 To 100
Line (Rnd * _Width, Rnd * _Height)-(Rnd * _Width, Rnd * _Height), _RGB32(Rnd * 255), BF
Next
Sleep
Dim test(4, 4) As object, A, B
A = 1: B = 2
testNewImage test(), A, B
Print test(A, B).img, test(A, B).wide, test(A, B).high
Sub testNewImage (outputObj() As object, A, B)
Dim SCR&
SCR& = _ScreenImage
outputObj(A, B).wide = _Width(SCR&) / 2
outputObj(A, B).high = _Height(SCR&) / 2
outputObj(A, B).img = _NewImage(outputObj(A, B).wide, outputObj(A, B).high, 32)
_PutImage , SCR&, outputObj(A, B).img, (0, 0)-(outputObj(A, B).wide - 1, outputObj(A, B).high - 1)
Cls
_PutImage , outputObj(A, B).img, 0
End Sub
@bplus well I must have something else out of whack. Thanks for your time.
It's not the having, it's the doing.
Posts: 347
Threads: 45
Joined: Jun 2024
Reputation:
32
02-18-2026, 11:16 PM
(This post was last modified: 02-18-2026, 11:18 PM by Unseen Machine.)
Its defo not a UDT thing as this is the basis of my entire Qb64 life!
AS youll see the params passed to the function work as a defacto
Code: (Select All)
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'///////////////////////////////////////////// Low Brow Libs ///////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'// ---- Part 1. Basic Type definitions and their Functions -----
'//
'// Using/creating a set of basic UDT's (User Defined Types) is the best way to start.
'// You can use these UDT's in your future programs to make coding obvious and easier.
'// Think of these as the foundations on which you build your programs.
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'// I will be using a Main Function to act as the main loop as i code in C/C++ and this is common practice I think people should
'// Learn from day 1 to make transistioning to modern languages easier later on
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'// Global shared variables
DIM SHARED Sys_State AS System_State '// This contains our basic program data, screen handle, input and timers
'// Whilst you can define this in your Main function, for other subs and functions to access it without
'// needing to have it passed as a parameter, i find this method more logical.
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Main '// Call the program
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SUB Main
'// First we set up using the system_state_new function. This creates our screen, initialises the input data and timers
System_State_New Sys_State, 0, 0, 800, 600, "Low Brow Dev"
DO
_LIMIT 144 '// 144 fps is the modern default as most modern screens have this refresh rate
'// Logic first
System_State_Update Sys_State '// Update the system data (timers and input) - later we can add screen resizing etc...
'// Graphics
CLS '// Clear the screen
PRINT "Mouse info"
PRINT
PRINT "X : " + STR$(Sys_State.Mouse.Position.X)
PRINT "Y : " + STR$(Sys_State.Mouse.Position.Y)
PRINT
PRINT "LB : " + STR$(Sys_State.Mouse.LB)
PRINT "RB : " + STR$(Sys_State.Mouse.RB)
PRINT "MB : " + STR$(Sys_State.Mouse.MB)
PRINT "MW : " + STR$(Sys_State.Mouse.MW)
_DISPLAY '// Update the display
LOOP UNTIL _EXIT '// Loop until the eXit button is pressed
'// Here you would free any memory youve allocated to avoid memory leaks
SYSTEM '// End the program
END SUB
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SUB Core_UDTS
'// A position in 2d space
TYPE Vector_2
X AS DOUBLE
Y AS DOUBLE
END TYPE
'// A rectangle
TYPE Rect
XY AS Vector_2 '// Top left corner
WH AS Vector_2 '// Width/Height of the rectangle
END TYPE
'// With those two UDT's, Screen position and resolution, Buttons, Mouse pointer position and more can be created
'// Next is the most basic of input devices, the mouse.
TYPE Mouse_State
LB AS _BYTE '// Left button
RB AS _BYTE '// Right Button
MB AS _BYTE '// Middle button
MW AS _BYTE '// Mouse wheel value
Position AS Vector_2 '// Current position
END TYPE
'// Next is the core of your program, the System_State. This should hold the resolution settings, input data and what ever else
'// you decide is a standard requirment
TYPE System_State
Screen_Handle AS LONG '// The handle returned by Screen _newimage
Screen_Rect AS Rect '// The dimensions and position of the screen
Screen_Title AS STRING * 32 '// the title of your program
Mouse AS Mouse_State '// Current input data
Old_Mouse AS Mouse_State '// Last input data - You can then compare the current vs this for just clicked or just released info
Time AS DOUBLE '// Created at the start of your program
Delta_Time AS DOUBLE '// The time since the the program was started
END TYPE
END SUB
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'// Now we have those defined we can start to use them. For specific things like the mouse and system we make
'// functions to update/create them.
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SUB System_State_New (System_State AS System_State, x#, y#, w#, h#, ScreenTitle$)
'// Screen dimension and position
System_State.Screen_Rect.XY.X = x#
System_State.Screen_Rect.XY.Y = y#
System_State.Screen_Rect.WH.X = w#
System_State.Screen_Rect.WH.Y = h#
'// Now we create the screen, set its position and set the title
System_State.Screen_Handle = _NEWIMAGE(w#, h#, 32)
SCREEN System_State.Screen_Handle
_TITLE ScreenTitle$
System_State.Screen_Title = ScreenTitle$
_SCREENMOVE x#, y# '// If you add full screen flag parameter you may wish to add an if clause here
'// set the system timers
System_State.Time = TIMER(.001)
System_State.Delta_Time = System_State.Time
'// Init input handlers
Mouse_State_Update System_State.Mouse
System_State.Old_Mouse = System_State.Mouse
END SUB
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SUB System_State_Update (System_State AS System_State)
System_State.Old_Mouse = System_State.Mouse '// Copy the old mouse data
Mouse_State_Update System_State.Mouse '// Get the new mouse data
'// Update the timers
System_State.Time = TIMER(.001)
System_State.Delta_Time = System_State.Time - System_State.Delta_Time
END SUB
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
SUB Mouse_State_Update (Mouse_State AS Mouse_State)
DO WHILE _MOUSEINPUT
Mouse_State.LB = _MOUSEBUTTON(1)
Mouse_State.RB = _MOUSEBUTTON(2)
Mouse_State.MB = _MOUSEBUTTON(3)
Mouse_State.Position.X = _MOUSEX
Mouse_State.Position.Y = _MOUSEY
Mouse_State.MW = Mouse_State.MW + _MOUSEWHEEL
LOOP
END SUB
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
'/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
It does not matter how much you embed the core (w/h) values, it will always work! and also as my code is
SCREEN System_State.Screen_Handle
and then uses a predefined newimage...none of the errors will exisit!
Unseen
|