• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

Help With DARK Basic

Joined
Feb 11, 2008
Messages
612 (0.10/day)
Location
DFW, Texas, USA
System Name Built By Me
Processor AMD 9800X3D
Motherboard Gigabyte X870 Aorus Elite WiFi7
Cooling Water Cooling - CPU Only - Heatkiller IV Pro - TG PhaseSheet PTM
Memory 32GB (2 x 16) - GSkill FlareX5 DDR5 6000 Mhz
Video Card(s) RTX 4080 - ASUS ROG Strix 16GB OC - P Mode
Storage 2TB Inland Performance Plus NVMe
Display(s) Alienware AW2723DF @ 280 Hz @ 1440P
Case Fractal Design Define S2
Audio Device(s) Corsair Virtuoso Pro Headset
Power Supply 1000W MSI MPG A1000G PCIE5
Mouse Razer Viper V3 Pro @ 2k Hz
Keyboard Asus ROG Strix Scope II 96 Wireless - ROG NX Snow Switches
Software Windows 11 Pro
We are using dark basic in school to make primitive video games. Does anybody know how to make text display for a certain amount of time, and then go away. I need the text to display for a certain amount of time while still having the game run, but with text in the center of the screen for awhile.
 
Are we talking about a textbox or some text on top of your game? eg "game over" in the middle of your screen?
 
Here is a simple run down of the game. It is a pong remake. There are two paddles on the screen, one on the left, and one on the other side. I already have it so that whenever the ball hits the paddle, "BAM!!!" is displayed in the center of the screen. I have tried a pause command for the text, but that pauses the entire program, not just the text. Needless to say, that is a useless command. I want it so that the game is still in play, but "BAM!!!" is displayed in the center of the screen for like 3 seconds.
 
You apparently already have the ability to place graphics on the screen, why not place a graphic saying "Bam!" in the middle of the screen?
 
I dont know DarkBASIC, but this is typically how you solve such an issue:

1./ The game needs to have a timer or clock. Either this is provided by DarkBasic as an inbuilt variable, or you need to create your own "counter". That would be some variable that starts at zero and is increased every second (if you can do that), or increases by 1 every time the game "loops". The problem with the second approach is that depending on the speed of the CPU, the timing will go out of whack. I'm sure DarkBASIC can solve this with "real timers".

2./ You consider any "timed" event, like your message, to be an object with a time constraint

3./ Show it, either print, or use the sprite routines

4./ Set how long you want it to display, as either a countdown timer, or as a limit when the game-clock reaches that value

5./ Remove it when your counter reaches zero, or when the game-clock > limit
 
Back
Top