Need Help in PB

Just starting out? Need help? Post your questions and find answers here.
SeeD
User
User
Posts: 16
Joined: Sat Jun 28, 2003 5:35 am
Contact:

Need Help in PB

Post by SeeD »

Code: Select all

If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc")
  If CreateImage (1, 100, 100 )
    If StartDrawing(ImageOutput())
      BackColor (128, 8, 128) ; purple
      Box(10,10,20,20)
StopDrawing()    
  
      
EndIf
EndIf
EndIf
how am i gonna do it so the PB will open a the program ??
i've compiled it and nothing come out ...
almost all the copy from the example source ~~
im just a beginer ... so please help me ...
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

SeeD,

There are two problems with your code.

First problem is that your window does not include the event loop.

This means that you are creating a window, and then your program ends. The window is then automatically destroyed.

Because PB is so lightening fast, you don't get to see a thing.

You need to put in a loop (doing the same thing over and over again) until the user closes the window.

like this:

Code: Select all


If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc") 
  If StartDrawing(WindowOutput()) 
    BackColor (128, 8, 128) ; purple 
    Box(10,10,20,20) 
    StopDrawing()    
  EndIf 
  Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
EndIf 

The second problem is that you are drawing onto an image. An image is an invisible thing that you use in the background, the user cannot see it.

If you want immediate results for your drawing, you should draw onto the window canvas direct (as above). If you do want to use a 'back' image first then you have to remember to draw it to the window when you've finished, otherwise it won't be seen.
SeeD
User
User
Posts: 16
Joined: Sat Jun 28, 2003 5:35 am
Contact:

Post by SeeD »

i got the 1 mistake smoothly ...
but 2nd mistake is the problem ...
if its a invisible thing in the background ... then how are we gonna edit it ??
------
another problem ...
i can't put the colors in the box or something ...
nvm ... i've know how to put the colors ...
ekek ...
now its the image thingie ~~ :) please explain ...
im just a beginer ... so please help me ...
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post by GedB »

Take a look at Image.pb in the examples directory.
SeeD
User
User
Posts: 16
Joined: Sat Jun 28, 2003 5:35 am
Contact:

Post by SeeD »

what code should i write to move the circle aside so i can see both the rectangular and the circle ??

Code: Select all

If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc") 
  If StartDrawing(WindowOutput()) 
    
    
    Box(20,20,30,60,RGB (12, 200, 80))
   
    Circle (40, 100, 70,RGB(240, 100, 50)) 
     
      FrontColor(255,0,0) ; Finally, red lines..
  For k=0 To 20
    Linexy(120,1+k*15,180, 100)
    Next
    
    

  
    
    StopDrawing()    
  EndIf 
  Repeat       
  Event = WaitWindowEvent() 
    Until Event = #PB_Event_CloseWindow 
EndIf 
i've used locate ... but i don't know where to put locate or its not the code ...
please help :)
im just a beginer ... so please help me ...
LarsG
Enthusiast
Enthusiast
Posts: 713
Joined: Mon Jun 02, 2003 1:06 pm
Location: Norway
Contact:

Post by LarsG »

You might want to do something like this:

Code: Select all

If OpenWindow(1, 100, 200, 300, 200, #PB_Window_SystemMenu, "abc") 
  If StartDrawing(WindowOutput())
    Box(20,20,30,60,RGB (12, 200, 80)) 
    Circle (130, 100, 70,RGB(240, 100, 50)) 
    FrontColor(255,0,0) ; Finally, red lines.. 
    For k=0 To 20 
      LineXY(260,1+k*15,210, 100) 
    Next 
    StopDrawing()
  EndIf 

Repeat
  Event = WaitWindowEvent() 
Until Event = #PB_Event_CloseWindow

EndIf 
You only use locate in conjuction with drawing text on the screen..
When you want to move graphics, you just adjust the x and y parametres..
(try hitting F1 when the cursor is on a graphics command, like "circle")

-Lars

AMD Athlon XP2400, 512 MB RAM, Hercules 3D Prophet 9600 256MB RAM, WinXP
PIII 800MHz, 320 MB RAM, Nvidia Riva Tnt 2 Mach 64 (32MB), WinXP + Linux
17" iMac, 1.8 GHz G5, 512 MB DDR-RAM, 80 GB HD, 64 MB Geforce FX 5200, SuperDrive, OSX
SeeD
User
User
Posts: 16
Joined: Sat Jun 28, 2003 5:35 am
Contact:

Post by SeeD »

yea ... thanks alot LarsG
yea ... i've tried reading the manual ...
but sometimes dun understand em ~~
im just a beginer ... so please help me ...
Post Reply