QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: PMACKAY on September 27, 2018, 02:04:29 am

Title: _PRINTMODE
Post by: PMACKAY on September 27, 2018, 02:04:29 am
Hi guys i am trying to print in text mode 0: default

with just a width command  (width 30,14) : color 6

i am using

_printmode keepbackground
_printstring(3,3),"just to show you")
_printmode _fillbackground

but i keep getting an error

Illegal function call on the line with _printmode keepbackground

any ideas as i want to keep the image below the text (behind it)
Title: Re: _PRINTMODE
Post by: SMcNeill on September 27, 2018, 02:07:24 am
Needs an underscore.

_KEEPBACKGROUND
Title: Re: _PRINTMODE
Post by: PMACKAY on September 27, 2018, 02:18:40 am
(i have the underscore in program and still experience the same error)

    _PRINTMODE _KEEPBACKGROUND
    _PRINTSTRING (1, 1), TIME$
    _PRINTMODE _FILLBACKGROUND
    _DISPLAY: _DELAY 0.10

this is the above (with an error for unknown reason)

when I remark out the two printmode lines, my programs works fine, but i would like to print the timer at the top whilest leaving the background behind it intact.

(Will be a proper timer but stuck this on to see if i can get printmode working)
Title: Re: _PRINTMODE
Post by: PMACKAY on September 27, 2018, 02:26:35 am
the timer is in the top left (I would like this displayed with the background in tact).. _display _keepbackground
Title: Re: _PRINTMODE
Post by: FellippeHeitor on September 27, 2018, 04:28:15 am
From the wiki:

Quote
The _PRINTMODE statement and function can only be used in graphic screen modes, not SCREEN 0

http://www.qb64.org/wiki/PRINTMODE
Title: Re: _PRINTMODE
Post by: PMACKAY on September 27, 2018, 05:59:10 am
thank you... I thought that was the case

Any Ideas on a

TI$="000000"


if ti$="003000" then 30 seconds went by

just seeing if there is a simple way of a timer like in sharp mz700 or zx spectrum basic. the ti$="000000" resets timer to zero then reading= "00" minutes, "30" seconds and "00" milliseconds

thats what the 000000 is... nothing fancy needed. it just calculates how long the loop is running for (eg. time on puzzle)

thanks.... just trying to avoid using timer on
Title: Re: _PRINTMODE
Post by: bplus on September 27, 2018, 08:15:38 am
Wait... what was wrong with printing TIME$ and TIMER?
Code: QB64: [Select]
  1.     CLS
  2.     LOCATE 1, 1
  3.     PRINT TIME$; ":";
  4.     PRINT RIGHT$(STR$(TIMER), 2)
  5.     _LIMIT 60
  6. LOOP UNTIL theCowsComeHome
  7.  

Oh I see. :(
Title: Re: _PRINTMODE
Post by: Petr on September 27, 2018, 09:21:34 am
do you miss a program that calculates time from a number? Maybe time from TIMER? I quickly pulled it out and edited it from my player. Perhaps the Czech names of the variables will not be damaging.

Code: QB64: [Select]
  1.     LOCATE 1, 1: PRINT timing$(TIMER)
  2. FUNCTION timing$ (hodnota AS DOUBLE) '                calculate time. Writed for Timer, _SndLen. Input format as TIMER or _SNDLEN WITH "."
  3.      IF hodnota < 60 THEN hodin = 0: minut = 0: sekund = hodnota: GOTO a1
  4.     IF hodnota > 60 AND hodnota < 3600 THEN hodin = 0: minut = hodnota / 60: GOTO a2
  5.     hodin = hodnota / 3600
  6.     hodin$ = STR$(hodin)
  7.     tecka = INSTR(0, hodin$, ".")
  8.     minut = (VAL("0." + RIGHT$(hodin$, LEN(hodin$) - tecka)) * 0.6) * 100
  9.     a2:
  10.     minut$ = STR$(minut)
  11.     tecka = INSTR(0, STR$(minut), ".")
  12.     sekund = (VAL("0." + RIGHT$(minut$, LEN(minut$) - tecka)) * 0.6) * 100
  13.     a1:
  14.     sekund$ = STR$(sekund)
  15.     tecka = INSTR(0, sekund$, ".")
  16.     sets = (VAL(RIGHT$(sekund$, LEN(sekund$) - tecka)) * 1)
  17.     timing$ = STR$(INT(hodin)) + ":" + STR$(INT(minut)) + ":" + STR$(INT(sekund)) + ":" + STR$(sets)
  18.  

minut = minute
hodin = hour
sekund = seconds
tecka = dot
hodnota = value
Title: Re: _PRINTMODE
Post by: bplus on September 27, 2018, 10:18:49 am
Yeah here is what I came up with:
Code: QB64: [Select]
  1. _TITLE "Click and hold down on title bar to stop time!"
  2. start## = TIMER
  3.     CLS
  4.     LOCATE 1, 1
  5.     PRINT TIME$
  6.     LOCATE 2, 4: PRINT timePassed$(start##)
  7.     _DELAY .09
  8. LOOP UNTIL theCowsComeHome
  9.  
  10. FUNCTION timePassed$ (started##)
  11.     tp## = TIMER - started##
  12.     t1$ = STR$(tp##)
  13.     dot = INSTR(t1$, ".")
  14.     t2$ = MID$(t1$, dot, 3)
  15.     t% = INT(tp##)
  16.     sec% = t% MOD 60
  17.     min% = INT(t% / 60) MOD 60
  18.     timePassed$ = STR$(min%) + ":" + RIGHT$(STR$(sec%), 2) + t2$
  19.  

PS will screw up after midnight.

EDIT: better not multiply tp## for t1$
Title: Re: _PRINTMODE
Post by: FellippeHeitor on September 27, 2018, 10:43:40 am
If start## > TIMER then start## = start## - 86400

Thatll fix your midnight issue.
Title: Re: _PRINTMODE
Post by: bplus on September 27, 2018, 10:49:57 am
Thanks Fellippe,

start## or started##
Code: QB64: [Select]
  1. _TITLE "Click and hold down on title bar to stop time!"
  2. start## = TIMER
  3.     CLS
  4.     LOCATE 1, 1
  5.     PRINT TIME$
  6.     LOCATE 2, 4: PRINT timePassed$(start##)
  7.     _DELAY .045
  8. LOOP UNTIL theCowsComeHome
  9.  
  10. FUNCTION timePassed$ (started##)
  11.     IF started## > TIMER THEN started## = started## - 86400
  12.     tp## = TIMER - started##
  13.     t1$ = STR$(tp##)
  14.     dot = INSTR(t1$, ".")
  15.     t2$ = MID$(t1$, dot, 3)
  16.     t% = INT(tp##)
  17.     sec% = t% MOD 60
  18.     min% = INT(t% / 60) MOD 60
  19.     timePassed$ = STR$(min%) + ":" + RIGHT$(STR$(sec%), 2) + t2$
  20.  

That will change started## once unless game play goes well beyond 24 hours...
Title: Re: _PRINTMODE
Post by: TempodiBasic on September 27, 2018, 02:05:41 pm
Hi guys

@bplus and other friends....

please can tell me what is it?
Quote
LOOP UNTIL theCowsComeHome

I'm just curious

Thanks
Title: Re: _PRINTMODE
Post by: bplus on September 27, 2018, 02:45:26 pm
Hi guys

@bplus and other friends....

please can tell me what is it?
Quote
LOOP UNTIL theCowsComeHome

I'm just curious

Thanks

;-))  Basically, B+ is just having fun!

theCowsComeHome = 0 because it was never set to any other value.

So Basically the line is saying

LOOP UNTIL 0

Or in other Basic words, LOOP forever!

It is a shortcut like saying:
Code: QB64: [Select]
  1.     'do stuff in this loop until you click the x box or you put an EXIT condition in the loop

Code: QB64: [Select]
  1. TRUE = -1
  2. iLoveBasic = TRUE
  3. WHILE iLOVEBASIC
  4.     ? "Hello Word!"

Thanks for paying attention TempodiBasic ;)


Attached is meaning of expression "Until the cows come home":
Title: Re: _PRINTMODE
Post by: PMACKAY on September 28, 2018, 12:36:01 am
THANK YOU GUYS!!!

I ended up using (funny i did not want to use timer() thinking would take a bit of work) but i ended up using timer which turned out so simple

T1 = _FREETIMER
_SNDLOOP GAMEMUSIC1&
ON TIMER(T1, 1) GOSUB TI
DO :'                                                  START OF PROGRAM LOOP (TRUST ME ITS MUCH BIGGER - 80+ LINES OF CODE BUT I LOVE IT AND SO ADDICTIVE TO PLAY)  "iTS MY NEW PUZZLE GAME"
TI=60
TIMER(T1) ON
IF TI=0 THEN :        '                           TIMER AT 0 SO OUT OF TIME

TI: TI = TI - 1: RETURN :'                    SUB TIMER COUNTER


I LOVE QB64
Title: Re: _PRINTMODE
Post by: PMACKAY on September 28, 2018, 12:35:50 pm
TIMERS working great (2xtimers for title) and (1xtimer for in game).. Also got my timer now running on screen without numbers (shows a bar for 60seconds / width of 4) looks great.

Working time Bar (YAY)
Title: Re: _PRINTMODE
Post by: FellippeHeitor on September 28, 2018, 12:40:43 pm
Looking good!
Title: Re: _PRINTMODE
Post by: PMACKAY on September 28, 2018, 01:30:08 pm
all in screen 0.. user def character set :) plays very good..

Need to finish score routines (High scores table, Game over section, Congratulate on completing levels fastest)... I kind of test run it and get stuck playing it :)

FORGOT TO MENTION "PRESS THE TAB IF YOU ARE STUCK" to restart level but beware lives=lives-1
Title: Re: _PRINTMODE
Post by: TempodiBasic on September 28, 2018, 05:17:42 pm
Hi PMACKAY
I find it cool
for music, for ASCII sprites and for kind of game.

Good Coding
Title: Re: _PRINTMODE
Post by: PMACKAY on September 28, 2018, 08:53:05 pm
thank you..