Hello world

Just starting out? Need help? Post your questions and find answers here.
pfaber11
Enthusiast
Enthusiast
Posts: 145
Joined: Sat Apr 13, 2019 12:17 pm

Hello world

Post by pfaber11 »

Having a problem changing the color of the window could some kind person show me where I'm going wrong .

Code: Select all

InitSprite()

OpenWindow(1,200,200,400,400,"pauls program")
ClearScreen(RGB(100,0,0))
FlipBuffers()
Delay(5000)
StartDrawing(WindowOutput(1))

DrawText(10,10,"hello world")
StopDrawing()

FlipBuffers()
Delay(5000)

End
pfaber11
Enthusiast
Enthusiast
Posts: 145
Joined: Sat Apr 13, 2019 12:17 pm

Re: Hello world

Post by pfaber11 »

This has had me pulling my hair out for hours and could really do with some help. Thanks for reading.
The code clearscreen(rgb(100,0,0)) should turn the window red but it doesn't . I am new to this and this is my second day.
In my profile it says I joined in April but never really did anything with pure basic but now I'm off and made a start.
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Hello world

Post by infratec »

You call ClearScreen(), but ... you have no Screen.
You have only a window :wink:

And you are mixing screen stuff with window stuff.

What do you want? A screen or a window?

And you need loops, not delays.

Have you looked in the help?
pfaber11
Enthusiast
Enthusiast
Posts: 145
Joined: Sat Apr 13, 2019 12:17 pm

Re: Hello world

Post by pfaber11 »

Ok thanks for the reply I'll go back and see if I can sort it .
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: Hello world

Post by infratec »

Code: Select all

EnableExplicit

Define Exit.i, Event.i

OpenWindow(0, 200, 200, 400, 400,"pauls program window")
CanvasGadget(0, 0, 0, 400, 400)

If StartDrawing(CanvasOutput(0))
  Box(0, 0, 400, 400, #Red)

  DrawText(10, 10, "hello world")
  StopDrawing()
EndIf

Repeat
  Event = WaitWindowEvent()
  
  Select Event
    Case #PB_Event_CloseWindow
      Exit = #True
      
  EndSelect
  
Until Exit


Exit = #False

InitSprite()
OpenWindow(0, 200, 200, 400, 400,"pauls program screen")
OpenWindowedScreen(WindowID(0), 0, 0, 400, 400)

ClearScreen(#Red)
If StartDrawing(ScreenOutput())
  DrawText(10, 10, "hello world")
  StopDrawing()
EndIf

Repeat
  Repeat
    Event = WindowEvent()
    
    Select Event
      Case #PB_Event_CloseWindow
        Exit = #True
      
    EndSelect
    
  Until Event = 0
  
  FlipBuffers()
  
Until Exit
But it depends what you want: an application or a game
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

Re: Hello world

Post by BarryG »

pfaber11 wrote:clearscreen(rgb(100,0,0)) should turn the window red
No, this turns the window red:

Code: Select all

SetWindowColor(WindowNumber,RGB(100,0,0))
pfaber11
Enthusiast
Enthusiast
Posts: 145
Joined: Sat Apr 13, 2019 12:17 pm

Re: Hello world

Post by pfaber11 »

OK thanks for all the input . It's all coming together now . I'm on day 6 of using pure basic .
Post Reply