Author Topic: _PRINTMODE  (Read 6575 times)

0 Members and 1 Guest are viewing this topic.

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
_PRINTMODE
« 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)
MackyWhite

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: _PRINTMODE
« Reply #1 on: September 27, 2018, 02:07:24 am »
Needs an underscore.

_KEEPBACKGROUND
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: _PRINTMODE
« Reply #2 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)
« Last Edit: September 27, 2018, 02:24:00 am by PMACKAY »
MackyWhite

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: _PRINTMODE
« Reply #3 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
MackyWhite

FellippeHeitor

  • Guest
Re: _PRINTMODE
« Reply #4 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

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: _PRINTMODE
« Reply #5 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
MackyWhite

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: _PRINTMODE
« Reply #6 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. :(
« Last Edit: September 27, 2018, 09:27:31 am by bplus »

Offline Petr

  • Forum Resident
  • Posts: 1720
  • The best code is the DNA of the hops.
    • View Profile
Re: _PRINTMODE
« Reply #7 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
« Last Edit: September 27, 2018, 09:27:13 am by Petr »

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: _PRINTMODE
« Reply #8 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$
« Last Edit: September 27, 2018, 10:27:09 am by bplus »

FellippeHeitor

  • Guest
Re: _PRINTMODE
« Reply #9 on: September 27, 2018, 10:43:40 am »
If start## > TIMER then start## = start## - 86400

Thatll fix your midnight issue.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: _PRINTMODE
« Reply #10 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...
« Last Edit: September 27, 2018, 12:29:20 pm by bplus »

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: _PRINTMODE
« Reply #11 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
Programming isn't difficult, only it's  consuming time and coffee

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: _PRINTMODE
« Reply #12 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":
« Last Edit: September 27, 2018, 03:33:36 pm by bplus »

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: _PRINTMODE
« Reply #13 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
« Last Edit: September 28, 2018, 01:54:17 am by PMACKAY »
MackyWhite

Offline PMACKAY

  • Forum Regular
  • Posts: 188
  • LIFE is Temporary
    • View Profile
Re: _PRINTMODE
« Reply #14 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)
« Last Edit: September 28, 2018, 12:37:17 pm by PMACKAY »
MackyWhite