Visual Basic

  • khayoz
  • Beginner
  • Beginner
  • khayoz
  • Posts: 44
  • Loc: Australia

Post 3+ Months Ago

Below is my visual basic code, im trying to get it to work, im using librty basic v2.02, but the dice will not show up beside each other, could anyone help me?




Code: [ Select ]
NoMainWin

Loadbmp "Dice1", "c:/OneB.bmp"
Loadbmp "Dice2", "c:/TwoB.bmp"
Loadbmp "Dice3", "c:/ThreeB.bmp"
Loadbmp "Dice4", "c:/FourB.bmp"
Loadbmp "Dice5", "c:/FiveB.bmp"
Loadbmp "Dice6", "c:/SixB.bmp"

Button #Win1.but1, "Roll", [PUSHRoll], UL, 25, 75
Button #Win1.but2, "Quit", [PUSHQuit], UL, 75, 75
Open "Button Up" for graphics_nsb as #Win1

Wait

[PUSHRoll]

For i = 1 to 5
  xpos = 50 + i * 2
  ypos = 50
  Dice = int(rnd(1)*6)+1
  If (Dice = 1) Then Print #Win1, "drawbmp Dice1 xpos ypos"
  If (Dice = 2) Then Print #Win1, "drawbmp Dice2 xpos ypos"
  If (Dice = 3) Then Print #Win1, "drawbmp Dice3 xpos ypos"
  If (Dice = 4) Then Print #Win1, "drawbmp Dice4 xpos ypos"
  If (Dice = 5) Then Print #Win1, "drawbmp Dice5 xpos ypos"
  If (Dice = 6) Then Print #Win1, "drawbmp Dice6 xpos ypos"
Next i

Wait
End
  1. NoMainWin
  2. Loadbmp "Dice1", "c:/OneB.bmp"
  3. Loadbmp "Dice2", "c:/TwoB.bmp"
  4. Loadbmp "Dice3", "c:/ThreeB.bmp"
  5. Loadbmp "Dice4", "c:/FourB.bmp"
  6. Loadbmp "Dice5", "c:/FiveB.bmp"
  7. Loadbmp "Dice6", "c:/SixB.bmp"
  8. Button #Win1.but1, "Roll", [PUSHRoll], UL, 25, 75
  9. Button #Win1.but2, "Quit", [PUSHQuit], UL, 75, 75
  10. Open "Button Up" for graphics_nsb as #Win1
  11. Wait
  12. [PUSHRoll]
  13. For i = 1 to 5
  14.   xpos = 50 + i * 2
  15.   ypos = 50
  16.   Dice = int(rnd(1)*6)+1
  17.   If (Dice = 1) Then Print #Win1, "drawbmp Dice1 xpos ypos"
  18.   If (Dice = 2) Then Print #Win1, "drawbmp Dice2 xpos ypos"
  19.   If (Dice = 3) Then Print #Win1, "drawbmp Dice3 xpos ypos"
  20.   If (Dice = 4) Then Print #Win1, "drawbmp Dice4 xpos ypos"
  21.   If (Dice = 5) Then Print #Win1, "drawbmp Dice5 xpos ypos"
  22.   If (Dice = 6) Then Print #Win1, "drawbmp Dice6 xpos ypos"
  23. Next i
  24. Wait
  25. End
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Code: [ Select ]
xpos = 50 + i * 2

is giving you : 102, 104, 106, 108, 110 Or 52, 54, 56, 58, 60 depending on how you look at it.

Assuming your dice are 50px wide, no matter how you look at the equation above you are overlapping the die before by 48px each time :wink:

using this should work (again assuming dice are 50px wide)
Code: [ Select ]
xpos = 50*i
  • khayoz
  • Beginner
  • Beginner
  • khayoz
  • Posts: 44
  • Loc: Australia

Post 3+ Months Ago

ok Thanks, how come its now in a black box?
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Khayoz Wrote : "ok Thanks, how come its now in a black box?"

If it wasn't wrapped inside
Code: [ Select ]

tags when you posted it then I must have edited the
Code: [ Select ]

tags into it before posting my answer & forgot to explain that part, Sorry about that. :oops:

We ask that all code being posted on the boards be wrapped inside
Code: [ Select ]

OR
PHP Code: [ Select ]
 
tags.

Post Information

  • Total Posts in this topic: 4 posts
  • Users browsing this forum: spork and 83 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
cron
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.