Author Topic: _PRINTSTRING Positioning Issue??  (Read 4248 times)

0 Members and 1 Guest are viewing this topic.

Offline Zeppelin

  • Newbie
  • Posts: 43
    • View Profile
    • Zeppelin Games ItchIo
_PRINTSTRING Positioning Issue??
« on: December 02, 2018, 08:17:03 pm »
Hey everyone,
I'm making a turn-based text fighting game, and previously when putting my 2 strings at
Code: QB64: [Select]
  1. _PRINTSTRING (w / 2 - 50, h / 10 * 3), player.name + "'S TURN"
and
Code: QB64: [Select]
  1. _PRINTSTRING (w / 2 - 50, h / 10 * 3.25), "ENEMY -" + STR$(patk) + " DMG"
they would sit nicely one under the other, but now they overlap and I'm unsure if I've done something or something else is affecting it.

To play the mode with the error:
Single-player -> Practice

Thanks,
Zep

The files are attached below if you want to read through the whole thing ( there are a heap of bugs) :)
* SLAY V4.bas (Filesize: 25.53 KB, Downloads: 242)
* SLAY V4.exe (Filesize: 6.56 MB, Downloads: 233)
+[--->++<]>+.+++[->++++<]>.[--->+<]>+.-[---->+<]>++.+[->+++<]>+.+++++++++++.----------.[--->+<]>----.+[---->+<]>+++.---[->++++<]>.------------.+.++++++++++.+[---->+<]>+++.+[->+++<]>++.[--->+<]>+.[->+++<]>+.++++++++++.+.>++++++++++.

Offline bplus

  • Global Moderator
  • Forum Resident
  • Posts: 8053
  • b = b + ...
    • View Profile
Re: _PRINTSTRING Positioning Issue??
« Reply #1 on: December 03, 2018, 08:46:08 am »
Here is a graphical illustration of the problem.
Code: QB64: [Select]
  1. DIM player.name AS STRING
  2. player.name = "B+"
  3. patk = 99.9999
  4.  
  5.  
  6. SCREEN _NEWIMAGE(800, 600, 32) '<<<<<<<<<<< this matters if h, w are related
  7. w = 500: h = 200
  8. WHILE h < 580
  9.     CLS
  10.     h = h + 20
  11.     LINE (0, 0)-STEP(w, h), , B
  12.     _PRINTSTRING (w / 2 - 50, h / 10 * 3), player.name$ + "'S TURN"
  13.     _PRINTSTRING (w / 2 - 50, h / 10 * 3.25), "ENEMY -" + STR$(patk) + " DMG"
  14.     _LIMIT 1
  15.  
  16.  
The way this is setup, h change will change the distance between the 2 lines. .25 * h/10 has to be just big enough to fit a new line.

Here is how B+ might fix it, but many other ways!
Code: QB64: [Select]
  1. DIM player.name AS STRING
  2. player.name = "B+"
  3. patk = 99.9999
  4.  
  5.  
  6.  
  7. SCREEN _NEWIMAGE(800, 600, 32)  '<<<<<<<<<<< this matters if h, w are related
  8. w = 500: h = 200
  9. WHILE h < 580
  10.     CLS
  11.     h = h + 20
  12.     LINE (0, 0)-STEP(w, h), , B
  13.     _PRINTSTRING (w / 2 - 50, h / 10 * 3), player.name$ + "'S TURN"
  14.     _PRINTSTRING (w / 2 - 50, h / 10 * 3 + fh), "ENEMY -" + STR$(patk) + " DMG"
  15.     _LIMIT 1
  16.  
  17.  
If just add the height of font to last line location, you have it made in the shade.

And say you want to add more lines:
Code: QB64: [Select]
  1. DIM player.name AS STRING
  2. player.name = "B+"
  3. patk = 99.9999
  4.  
  5.  
  6.  
  7. SCREEN _NEWIMAGE(800, 600, 32) '<<<<<<<<<<< this matters if h, w are related
  8. w = 500: h = 200
  9. WHILE h < 580
  10.     CLS
  11.     h = h + 20
  12.     LINE (0, 0)-STEP(w, h), , B
  13.     _PRINTSTRING (w / 2 - 50, h / 10 * 3), player.name$ + "'S TURN"
  14.     _PRINTSTRING (w / 2 - 50, h / 10 * 3 + fh), "ENEMY -" + STR$(patk) + " DMG"
  15.     FOR i = 1 TO 5
  16.         Bline$ = "Here is B+" + STR$(i) + " centered line added."
  17.         _PRINTSTRING (w / 2 - LEN(Bline$) * fw / 2, h / 10 * 3 + (i + 1) * fh), Bline$
  18.     NEXT
  19.     _LIMIT 1
  20.  
  21.  
« Last Edit: December 03, 2018, 10:12:19 am by bplus »

Offline Zeppelin

  • Newbie
  • Posts: 43
    • View Profile
    • Zeppelin Games ItchIo
Re: _PRINTSTRING Positioning Issue??
« Reply #2 on: December 03, 2018, 07:03:09 pm »
Ah, I see.
Thanks for your detailed explanation bplus

Zep
+[--->++<]>+.+++[->++++<]>.[--->+<]>+.-[---->+<]>++.+[->+++<]>+.+++++++++++.----------.[--->+<]>----.+[---->+<]>+++.---[->++++<]>.------------.+.++++++++++.+[---->+<]>+++.+[->+++<]>++.[--->+<]>+.[->+++<]>+.++++++++++.+.>++++++++++.