01-27-2024, 03:39 PM
(This post was last modified: 01-27-2024, 03:41 PM by Ra7eN.
Edit Reason: spelling
)
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:
Full Code (WIP)
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
3 out of 2 people have trouble with fractions