none
Small Basic Game Graphics RRS feed

  • General discussion

  • The following is a sample program that shows pretty much all the features of SmallBasic capabilities with regard to graphics. 

    I intentionally used almost all of the GaphicsWindows and Shapes commands at one point or other to show how they are used and can be put together.

    It starts simply and progresses to more complex coding.  The idea is to cover all graphics, shapes and mouse/keyboard control typically used for SB games (certainly those I have seen).  It can be used to see the syntax of commands and how they can be used to achieve different effects. 

    The ideas can then be developed into other projects or the program can be modified and experimented with to see what is happening.  Suitable segments can be copied to another project as a starting point.

    In order to use this program you will have to look at the code to see what is expected and what it does.

    Import XZG681 into SB.
    Saturday, July 4, 2009 11:41 PM
    Moderator

All replies

  • Really nice!
    Only thing I can propose is slightly change of 10 balls phase. When you are detecting mouse cursor is over ball you can store exact mouse position relative to ball center not only ball index. Then you can use this relative position to modify ball coordinates.

    Something like this from line 94:

        'If no ball selected, then check if we are over one
        If (iball = 0) Then
          For i = 1 To nball
            If (xm >= x[i]-radius And xm <= x[i]+radius And ym >= y[i]-radius And ym <= y[i]+radius) Then
              iball = i
              xrel = x[i]-xm
              yrel = y[i]-ym
              'To change the colour we delete it and replace it with a new ball
              GraphicsWindow.BrushColor = "Pink"
              Shapes.Remove(balls[iball])
              balls[iball] = Shapes.AddEllipse(2*radius,2*radius)
              'We are finished and don't want to continue checking since we have already deleted a ball so end this loop
              Goto completed1
            EndIf
          EndFor
        EndIf
        completed1:
        'Move selected ball
        If (iball > 0) Then
          ball = balls[iball]
          x[iball] = xm+xrel
          y[iball] = ym+yrel
          Shapes.Move(ball,x[iball]-radius,y[iball]-radius)
        EndIf
    


    I hate publish my code online because always people tell me it is not so good I think ;)
    Grzesio
    Sunday, July 5, 2009 7:27 AM
  • Absolutely right - I was trying to give a progressive set of examples that can be used to see how to do the basics and provide an example of most graphics keywords being used in one relatively concise bit of code.   The methods can certainly be extended, improved and refined - I hope they are and used as starting points for new programmers having fun writing their own.
    Sunday, July 5, 2009 9:33 AM
    Moderator
  • The following is a sample program that shows pretty much all the features of SmallBasic capabilities with regard to graphics. 

    I intentionally used almost all of the GaphicsWindows and Shapes commands at one point or other to show how they are used and can be put together.

    It starts simply and progresses to more complex coding.  The idea is to cover all graphics, shapes and mouse/keyboard control typically used for SB games (certainly those I have seen).  It can be used to see the syntax of commands and how they can be used to achieve different effects. 

    The ideas can then be developed into other projects or the program can be modified and experimented with to see what is happening.  Suitable segments can be copied to another project as a starting point.

    In order to use this program you will have to look at the code to see what is expected and what it does.

    Import XZG681 into SB.

    looks fun, i love the idea of your sample idea program whereby there is a program that will run a custamizable "show me what it dos if i change (this) type scenario" it could also be rewrttin az a "how do you change (this)todo(this)" type .QnA program.
    is turtle a capabilitie ? if not is it a function?  and what is flick?
    Sunday, July 5, 2009 8:29 PM
  • Neat!  Love the soccer ball, complete with rotation.

    Monday, July 6, 2009 5:21 PM
    Moderator
  • http://www.windowswiki.info/wp-content/uploads/smallbasic_logo.png is returning a 404 Not Found error which causes the program to crash.

    Wednesday, July 8, 2009 2:22 AM
  • Hi, it looks like this image has disappeared from the net - modified code can by imported using reference VKB520.
    Wednesday, July 8, 2009 6:01 PM
    Moderator