Board Logo
« Graphics window print left justified »

Welcome Guest. Please Login or Register.
Jan 21st, 2018, 02:58am


Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Please use the forums Search feature before asking.
Please post code using the code box described in Format Your Messages.
This will keep indentation, separate it better form the message and prevent gibberish.
If the code is too long for one post or additional files are needed, upload a ZIP archive to the Just BASIC Files Archive Site.

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Graphics window print left justified  (Read 121 times)
Rob Somerville
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 17
xx Graphics window print left justified
« Thread started on: Dec 24th, 2017, 11:28am »

I am trying to write a small dice throwing program to use while playing a backgammon app.
My latest attempt is shown below and is ok. It simply rolls two dice, tells me the result and loops until I press Q to Quit.

If I do not have the line, 'print #1, "home"' then the pair of numbers moves down the window and disappears. I would really like it to print the result, say 5 and 2 vertically, not horizontally as it does at present. This is, no doubt, very easy, but I just can't figure it out. Any ideas anybody?
Code:
    nomainwin
    WindowWidth = 120
    WindowHeight = 120
    UpperLeftX = 1300
    UpperLeftY = 150
    open "Dice" for graphics as #1
    print #1, "when characterInput [keyPressed]"
    print #1, "trapclose [quit]"
    print #1, "font arial 30"
    print #1, "\This is Arial 30 point"

[loopHere]
    print #1, "setfocus"
    scan
    for n = 1 to 2
        c = int(rnd(1)*6) + 1
        if n = 1 then a = c else b = c
        if c=1 then playwave "voice\one.wav"
        if c=2 then playwave "voice\two.wav"
        if c=3 then playwave "voice\three.wav"
        if c=4 then playwave "voice\four.wav"
        if c=5 then playwave "voice\five.wav"
        if c=6 then playwave "voice\six.wav"
        if n=1 then playwave "voice\and.wav"
      next
      print #1, "home"
      print #1, "\";a;" ";b
      wait

[keyPressed]
    print#1, "cls"
    key$ = Inkey$
    if key$ = "q" or key$ = "Q" then goto [quit]
    goto [loopHere]


[quit]
    close #1
    end

 
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3636
xx Re: Graphics window print left justified
« Reply #1 on: Dec 24th, 2017, 3:05pm »

err
Code:
      print #1, "home"
      'print #1, "\";a;" ";b
      print #1, "\";a
      print #1, "\";b 

?
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Rob Somerville
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 17
xx Re: Graphics window print left justified
« Reply #2 on: Dec 25th, 2017, 2:27pm »

Thank you. I can't believe that I didn't try this as my very first attempt and then several more times since this is the obvious answer. I have no explanation, but thanks embarassed

print #1, "home" This command centers the pen in the graphics window. Is there any way of placing the pen at the left of graphics window?
User IP Logged

tsh73
JB-Supporter


member is offline

Avatar




PM

Gender: Male
Posts: 3636
xx Re: Graphics window print left justified
« Reply #3 on: Dec 26th, 2017, 02:42am »

top left
Code:
      print #1, "place 0 0" 'top left
      print #1, "\"         'skip one line or it'll be up (out of) screen
      print #1, "\";a
      print #1, "\";b
 

center left
Code:
      print #1, "home"
      print #1, "posxy cx cy"   'read center position in cx, cy
      print #1, "place 0 ";cy 'center left
      print #1, "\";a
      print #1, "\";b
 
User IP Logged

Q: "And if I took your codes and compile them, and sell them for a profit"?
A: Go ahead. I had my share of good then I coded it for fun, if you can make better use of it - please do.
(enjoying JB 1.01 on WinXP, netbook and desktop)
Rob Somerville
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 17
xx Re: Graphics window print left justified
« Reply #4 on: Dec 26th, 2017, 04:10am »

Thank you smiley
User IP Logged

Rob Somerville
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 17
xx Re: Graphics window print left justified
« Reply #5 on: Jan 11th, 2018, 2:33pm »

nomainwin
WindowWidth = 60
WindowHeight = 160
UpperLeftX = 1500
UpperLeftY = 150
open "Dice" for graphics as #1
print #1, "when characterInput [keyPressed]"
print #1, "trapclose [quit]"
print #1, "font arial 30"
print #1, "\This is Arial 30 point"

[loopHere]
print #1, "setfocus"
scan
for n = 1 to 2
c = int(rnd(1)*6) + 1
if n = 1 then a = c else b = c
next
print #1, "place 15 0"
print #1, "\"
print #1, "\";a
print #1, "\";b
timer 10 'Without this a and b do not show for a few seconds
if a=1 then playwave "voice\one.wav"
if a=2 then playwave "voice\two.wav"
if a=3 then playwave "voice\three.wav"
if a=4 then playwave "voice\four.wav"
if a=5 then playwave "voice\five.wav"
if a=6 then playwave "voice\six.wav"
playwave "voice\and.wav"
if b=1 then playwave "voice\one.wav"
if b=2 then playwave "voice\two.wav"
if b=3 then playwave "voice\three.wav"
if b=4 then playwave "voice\four.wav"
if b=5 then playwave "voice\five.wav"
if b=6 then playwave "voice\six.wav"
wait

[keyPressed]
print#1, "cls"
key$ = Inkey$
if key$ = "q" or key$ = "Q" then goto [quit]
goto [loopHere]

[quit]
close #1
end

This works well. Thank you smiley
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

Conforums Terms of Service | Membership Rules | Home | Search | Recent Posts | Notification | Format Your Message | Installation FAQ

Donate $6.99 for 50,000 Ad-Free Pageviews!

| |

This forum powered for FREE by Conforums ©
Sign up for your own Free Message Board today!
Terms of Service | Privacy Policy | Conforums Support | Parental Controls