Welcome, Guest |
You have to register before you can post on our site.
|
Forum Statistics |
» Members: 484
» Latest member: BigDog
» Forum threads: 2,799
» Forum posts: 26,418
Full Statistics
|
|
|
Stack size limit for If/Then statements? |
Posted by: JamesAlexander - 01-28-2024, 10:59 PM - Forum: General Discussion
- Replies (20)
|
|
Hi All,
I'm developing a program where I am implementing a lot of if/then statements to do logic, but the way it is designed, I will have to use a lot of straight logical statements. I have tried using this through DATA statements and arrays, dimension the arrays as $'DYNAMIC, etc...so I am just going the straightforward route.
A sample line for an IF / THEN statement is just this:
IF Lookahead$ = CHR$ (0) THEN G$="XXXXXXX": PUT #2 , ,G$ : G$=""
where the line has about 3 or less multi-statements, and only if they are true. Is is simple, but there are many of them. I am already using a logic tool to automate the process, that is why I cannot do it another way. The automation is simple and straightforward, at the expense of stack space because each of the statements are automatically generated and then can be used in QB64 code.
The kicker is, I have about 9,786 lines that I can use successfully - anything more, I will get a C++ error.
I think it has to do with the Main() sub being limited to approximately 10,000 lines or less (9,786 exactly), but am not entirely sure.
How can I increase the number of logic statements and conditionals that are outside of arrays? Is it just the stack space, or will I have to do it another way?
What are my options with this? I have tried using CLEAR, and that won't do either. Is it possible to somehow allocate a tremendous amount of stack size at the risk of very minimal variables? Or perhaps edit and recompile a modified version of Qb64Pe source code that will work for this increasing the line numbers and limits?
Thanks,
James
|
|
|
Color Extraction Developer Insights |
Posted by: TerryRitchie - 01-28-2024, 06:28 AM - Forum: Help Me!
- Replies (11)
|
|
I'm writing a few image manipulation routines and need them to be as fast as possible. I'm using bit manipulation to extract pixel color information like so:
(all of the variables have been declared properly beforehand)
_MEMGET m, o, p ' get pixel at offset within image memory block
a = 4278190080 AND p ' extract alpha
r = 16711680 AND p ' extract red
g = 65280 AND p ' extract green
b = 255 AND p ' get blue level (0 to 255)
a = _SHR(a, 24) ' get alpha level (0 to 255) (divide by 16777215)
r = _SHR(r, 16) ' get red level (0 to 255) (divide by 65536)
g = _SHR(g, 8) ' get green level (0 to 255) (divide by 256)
I need some insight from the developers regarding _ALPHA32(), _RED32(), _GREEN32(), and _BLUE32(). Is my bit manipulation faster than using these statements or are they handled internally using the same method (or an even faster method I'm unaware of)?
Loving the memory manipulation statements by the way. Man, have I been missing out by not using them regularly.
|
|
|
Clicker template game |
Posted by: Ra7eN - 01-27-2024, 03:39 PM - Forum: Works in Progress
- No Replies
|
|
I still am stuck on idle, incremental and clicker games and was curious it I could pull it off in qb64. I can!!
however got bored. Here is some starter code for someone that wants to play with it. currently it works, little buggy on display. but hey, have fun!!
note: I use the "ADVENTURE CAPITALIST" CLICKER game for inspiration. long ways off but this is the core.
It is all thanks to this hidden gem routine:
Code: (Select All)
' Set up the timer event for game upkeep
UpdateTimer = _FREETIMER
ON TIMER(UpdateTimer, 0.5) GameUpkeep
TIMER(UpdateTimer) ON
Full Code (WIP)
Code: (Select All)
screen 12
CONST TRUE = 1
CONST FALSE = 0
TYPE PurchasableItem
Name AS STRING
Count AS INTEGER
Cost AS DOUBLE
ProductionRate AS DOUBLE
END TYPE
TYPE Operator
Name AS STRING
Cost AS DOUBLE
ManagedItemIndex AS INTEGER
Owned AS INTEGER
END TYPE
' Define the data for each item
DATA "Nebula Collector",50,0.5
DATA "Space Rover",500,2
DATA "Asteroid Miner",2500,10
DATA "Cosmic Observatory",12000,40
DATA "Interstellar Probe",60000,100
DATA "Wormhole Excavator",300000,500
DATA "Quantum Research Lab",1500000,2000
DATA "Galactic Trading Post",7500000,8000
DATA "Alien Artifact Hunter",37500000,40000
DATA "Dimensional Gateway",187500000,100000
DIM SHARED Stardust AS DOUBLE
DIM SHARED UpdateTimer AS INTEGER
DIM SHARED Items(10) AS PurchasableItem
DIM SHARED Operators(1 TO 10) AS Operator
' Read the data and initialize each item
FOR I = 1 TO 10
READ Items(I).Name, Items(I).Cost, Items(I).ProductionRate
Items(I).Count = 0
NEXT I
' Initialize Operators
DATA "Basic Drone",10000,1
DATA "Advanced Drone",50000,2
DATA "Mining Robot",250000,3
DATA "Observatory AI",1250000,4
DATA "Probe Navigator",6250000,5
DATA "Wormhole Technician",31250000,6
DATA "Quantum Scientist",156250000,7
DATA "Galactic Trader",781250000,8
DATA "Artifact Analyst",3906250000,9
DATA "Dimensional Engineer",19531250000,10
FOR I = 1 TO 10
READ Operators(I).Name, Operators(I).Cost, Operators(I).ManagedItemIndex
Operators(I).Owned = FALSE
NEXT I
' Set up the timer event for game upkeep
UpdateTimer = _FREETIMER
ON TIMER(UpdateTimer, 0.5) GameUpkeep
TIMER(UpdateTimer) ON
DO
CLS
PRINT "Stardust: "; Stardust
PRINT "============================================"
PRINT
PRINT "Press 'C' to collect Stardust."
PRINT "Press 'Q' to quit the game."
PRINT
PRINT "Upgrades:"
' Display all upgrades with their stats
FOR I = 1 TO 10
IF Items(I).Cost <= Stardust THEN
COLOR 10 ' Set text color to lime (color code 10)
IF I < 10 THEN
PRINT "Press "; STR$(I); " to buy "; Items(I).Name; ": "; Items(I).Count; " | Cost: "; Items(I).Cost
ELSE
PRINT "Press 0 to buy "; Items(I).Name; ": "; Items(I).Count; " | Cost: "; Items(I).Cost
END IF
ELSE
COLOR 15 ' Set text color to white (default color code)
PRINT Items(I).Name; ": "; Items(I).Count; " | Cost: "; Items(I).Cost
END IF
NEXT I
COLOR 15 ' Reset text color to white for the rest of the text
PRINT "Operators:"
' Display all operators with their stats
' Change color to lime if the player can afford the operator and it's not already owned
FOR I = 1 TO 10
IF Operators(I).Cost <= Stardust AND Operators(I).Owned = FALSE THEN
COLOR 10 ' Set text color to lime (color code 10)
ELSE
COLOR 15 ' Set text color to white (default color code)
END IF
PRINT Operators(I).Name; ": Cost "; Operators(I).Cost; ", Managed Upgrade: "; Items(Operators(I).ManagedItemIndex).Name
NEXT I
COLOR 15 ' Reset text color to white for the rest of the text
DIM userInput AS STRING
userInput = INKEY$
SELECT CASE LCASE$(userInput)
CASE "c"
Stardust = Stardust + 1
CASE "1", "2", "3", "4", "5", "6", "7", "8", "9"
IF Stardust >= Items(VAL(userInput)).Cost THEN
PurchaseItem VAL(userInput)
END IF
CASE "0"
IF Stardust >= Items(10).Cost THEN
PurchaseItem 10
END IF
CASE "q"
END ' Quit the game
END SELECT
_LIMIT 30
LOOP
'$include: 'utils_2023.bi'
SUB GameUpkeep
FOR i = 1 TO 10
IF Operators(i).Owned THEN
Stardust = Stardust + (Items(Operators(i).ManagedItemIndex).Count * Items(Operators(i).ManagedItemIndex).ProductionRate)
END IF
NEXT i
END SUB
SUB PurchaseItem (ItemIndex AS INTEGER)
IF Stardust >= Items(ItemIndex).Cost THEN
Stardust = Stardust - Items(ItemIndex).Cost
Items(ItemIndex).Count = Items(ItemIndex).Count + 1
Items(ItemIndex).Cost = Items(ItemIndex).Cost * 1.15
END IF
' Increase the ProductionRate per click instead of auto-generating Stardust
Items(ItemIndex).ProductionRate = Items(ItemIndex).ProductionRate + SOME_INCREMENT_VALUE
END SUB
|
|
|
FUNCTION Event(x AS DOUBLE) AS DOUBLE |
Posted by: Dimster - 01-26-2024, 04:17 PM - Forum: Help Me!
- Replies (4)
|
|
Before creating a function I normally would Dimension x as Double BEFORE I actually call the function. For example
Dim x as Double
...code..
...code..
x = Event
...
Function Event(x)
...code...
End Function
But, dimensioning on an "as needed basis" or "on the run" what is the correct syntax
Function Event (x as Double) as Double or Function Event(x) as Double or Function Event (x as Double)??
It's hard to give up on the old ways, if they worked, to learn a new more efficient way. (by efficient I mean to reduce all those Dim Shared variables I have at the beginning of my code to only creating them when they are actually called for service.
|
|
|
extra icon in taskbar running QB64PE in Windows 11 |
Posted by: madscijr - 01-26-2024, 01:44 PM - Forum: General Discussion
- Replies (4)
|
|
I recently got a new computer which came with Windows 11, and running QB64PE 3.10.0 on it, I can't help but notice an extra command prompt icon shows up in the taskbar (see screenshot). The prompt is mostly blank with "QB64PE.exe" in it. Is this normal? If I right-click on it in the taskbar and select Close Window, the QB64PE IDE closes as well, so I guess it's needed. Is there any configuration I can do to hide it or make it go away? Any info appreciated!
PS Here is my system info, if it helps:
Code: (Select All) Processor Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz 2.30 GHz
Installed RAM 32.0 GB (31.8 GB usable)
System type 64-bit operating system, x64-based processor
Pen and touch Touch support with 10 touch points
Edition Windows 11 Pro
Version 22H2
Installed on 12/30/2023
OS build 22621.3007
Experience Windows Feature Experience Pack 1000.22681.1000.0
|
|
|
_ERRORLINE abilities |
Posted by: MichelleL - 01-24-2024, 11:55 PM - Forum: Help Me!
- Replies (7)
|
|
I'm kind of not even sure how to phrase this question. _ERRORLINE will display the line where and error is found. But say I wanted to use the command to display something different depending on where the error is found. As in bounding the error to within a section of code, as in:
If _ErrorLine > 100and _ErrorLine < 150 Print "This section of code"
If _ErrorLine > 200and _ErrorLine < 250 Print "This other section of code"
Well, that is good, so long as I don't add more code prior to these two lines, in which case I have to keep tabs on those lines and change them each time I add or subtract prior code. Is there an ability to 'tag' something to use in place of the values? Or, maybe a different command.....
|
|
|
QBJS - Videos |
Posted by: dbox - 01-24-2024, 07:06 PM - Forum: QBJS, BAM, and Other BASICs
- Replies (1)
|
|
Thought I would create a new thread as a place to collect QBJS videos as they are available. I'm not a youtuber myself, but there are others out there creating some great content.
It's More Fun to Compute #4 - QBJS Profile in VSCode
@grymmjack covers a lot of ground with this one. In addition to the in-depth walkthrough of how to create a QBJS profile in VSCode, the first several minutes of the video contain a great general overview of the QBJS IDE and project.
QBJS Is a QBasic Like Interpreter For the Web
This is a great little intro to QBJS by RetroNick. There's even a shoutout to BAM in this one. RetroNick also has a number of QB64 videos on his channel.
|
|
|
|