none
the original paddle game

    Question

  • can some please explain to me where the line of code is that defines the colors of the paddle and the ball, or is there some sort of default?

    'PADDLE GAME
    GraphicsWindow.BackgroundColor = "DarkBlue"
    paddle = Shapes.AddRectangle(120, 12)  
    ball = Shapes.AddEllipse(16, 16)       
    GraphicsWindow.MouseMove = OnMouseMove 
    x = 0                                  
    y = 0                                  
    deltaX = 1                             
    deltaY = 1                             
    RunLoop:                               
    x = x + deltaX                         
    y = y + deltaY                         
    gw = GraphicsWindow.Width              
    gh = GraphicsWindow.Height             
    If (x >= gw - 16 Or x <= 0) Then       
      deltaX = -deltaX                     
    EndIf                                  
    If (y <= 0) Then                  
      deltaY = -deltaY                     
    EndIf                                  
    padX = Shapes.GetLeft(paddle)          
    If (y = gh - 28 And x >= padX And x <= padX + 120) Then
      deltaY = -deltaY                     
    EndIf                                  
    Shapes.Move(ball, x, y)                
    Program.Delay(5)                       
    If (y < gh) Then                       
      Goto RunLoop                         
    EndIf                                  
    GraphicsWindow.ShowMessage("You lose", "Paddle")
    Sub OnMouseMove                        
      paddleX = GraphicsWindow.MouseX      
      Shapes.Move(paddle, paddleX - 60, GraphicsWindow.Height - 12)
    EndSub

    i would really like to know this as i am just starting out and i just don't see it.

    Well, I feel a whole heck of a lot more like I do now than I did a little while ago!!?!

    Wednesday, June 06, 2012 12:50 AM

Answers

  • 'PADDLE GAME
    
    GraphicsWindow.BackgroundColor = "Khaki"
    
    ' From now on, all shapes created will have a border thickness = PenWidth pixels:
    GraphicsWindow.PenWidth = 3
    
    ' From now on, all shapes created will have a border color = PenColor:
    GraphicsWindow.PenColor   = "Green"
    
    ' From now on, all shapes created will have a paint  color = BrushColor:
    GraphicsWindow.BrushColor = "DarkGray"
    paddle = Shapes.AddRectangle(120  12)
    
    ' BrushColor gets a color change now, So the ball shape will have these characteristics:
    ' paint color = "Red", border color = "Green" and border thickness = 3 pixels
    GraphicsWindow.BrushColor = "Red"
    ball   = Shapes.AddEllipse(16  16)


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoopEditor Wednesday, June 06, 2012 5:56 AM
    • Marked as answer by Namyegob Wednesday, June 06, 2012 5:24 PM
    Wednesday, June 06, 2012 5:53 AM

All replies

  • 'PADDLE GAME
    
    GraphicsWindow.BackgroundColor = "Khaki"
    
    ' From now on, all shapes created will have a border thickness = PenWidth pixels:
    GraphicsWindow.PenWidth = 3
    
    ' From now on, all shapes created will have a border color = PenColor:
    GraphicsWindow.PenColor   = "Green"
    
    ' From now on, all shapes created will have a paint  color = BrushColor:
    GraphicsWindow.BrushColor = "DarkGray"
    paddle = Shapes.AddRectangle(120  12)
    
    ' BrushColor gets a color change now, So the ball shape will have these characteristics:
    ' paint color = "Red", border color = "Green" and border thickness = 3 pixels
    GraphicsWindow.BrushColor = "Red"
    ball   = Shapes.AddEllipse(16  16)


    Click on "Propose As Answer" if some post solves your problem or "Vote As Helpful" if some post has been useful to you! (^_^)

    • Edited by GoToLoopEditor Wednesday, June 06, 2012 5:56 AM
    • Marked as answer by Namyegob Wednesday, June 06, 2012 5:24 PM
    Wednesday, June 06, 2012 5:53 AM
  • Ah! I see. So i CAN define my own colors for said items, which the original program doesn't do, leading me to believe that there IS a default built into Small Basic! Thank you!!?!

    Well, I feel a whole heck of a lot more like I do now than I did a little while ago!!?!

    Wednesday, June 06, 2012 5:24 PM