Results 1 to 4 of 4

Thread: How to create analog clock using Small Basic

  1. #1
    Join Date
    May 2008
    Posts
    176

    How to create analog clock using Small Basic

    Here is a new episode of our introduction to programming using the ultra-simple language, specifically designed to restore the idea of a fun and entertaining programming as in 80 years. Today we will discover a new feature: timers!

    Small Basic

    Small Basic is a language introduction to programming that emphasizes the idea of fun in programming. It is for this new Microsoft initiative aimed at encouraging more young people (7 to 77 years) to discover the joys of programming.

    - Download Small Basic

    - Install it by following the wizard step by step

    - At launch, Small Basic automatically recognizes the language of your system and adapts accordingly. In other words, the software displays an interface and help when launched on a Windows system.

    - In the following two steps, we will discover a new direction (Timer) function and the amazing publication very Web 2.0.

  2. #2
    Join Date
    May 2008
    Posts
    176

    re: How to create analog clock using Small Basic

    Using Timers

    The Timers can trigger the execution of a subprogram (SUB) at regular intervals. It is very good in games to move enemies or decorative elements. This is also useful when you want to automatically refresh a display.

    To implement a Timer, you must use the new keyword and TIMER functions.

    - We start by defining an interval using: TIMER.INTERVAL = x (where x is a number in milliseconds). For example: "Timer.Interval = 1000" trigger an event every second.

    - Then what tells the program sub-program must perform by giving it a name with TIMER.TICK = NameOfSub

    This gives something like this:
    ...
    Timer.Interval = 500
    Timer.Tick = MoveTimer
    ...
    Sub MoveTimer
    'Insert the code for moving enemies
    EndSub

    - To pause a timer, use the command: TIMER.PAUSE ()

    - To restart a suspended Timer, use the command: TIMER.RESUME ()

  3. #3
    Join Date
    May 2008
    Posts
    176

    re: How to create analog clock using Small Basic

    Delivering a clock

    The following program displays an analog clock with hands for hours and minutes, and its second hand seconds.

    Code:
    'Beginning of program 
    ' 
    xRAD = math.pi / 180 
    
    ' 
    GraphicsWindow.Height = 200 
    GraphicsWindow.Width = 200 
    GraphicsWindow.BackgroundColor = "Black" 
    GraphicsWindow.Show () 
    ' 
    Timer.Interval = 1000 
    ShowTime Timer.Tick = 
    ' 
    'End of program 
    ' 
    Sub ShowTime 
    Sec = 6 * Clock.Second 
    Clock.Minute * min = 6 
    Heu Clock.Hour * = 30 
    ' 
    GraphicsWindow.Clear () 
    GraphicsWindow.PenColor = "Yellow" 
    GraphicsWindow.DrawEllipse (0,0,200,200) 
    ' 
    X = 100 + (90 * Math.sin (xRAD * Sec)) 
    Y = 100 - (90 * Math.Cos (xRAD * Sec)) 
    GraphicsWindow.DrawLine (100.100, X, Y) 
    ' 
    GraphicsWindow.PenColor = "Green" 
    X = 100 + (80 * Math.sin (xRAD * Min)) 
    Y = 100 - (80 * Math.Cos (xRAD * Min)) 
    GraphicsWindow.DrawLine (100.100, X, Y) 
    ' 
    GraphicsWindow.PenColor = "Red" 
    X = 100 + (60 * Math.sin (xRAD Heu *)) 
    Y = 100 - (60 * Math.Cos (Heu xRAD *)) 
    GraphicsWindow.DrawLine (100.100, X, Y) 
    ' 
    GraphicsWindow.PenColor = "Cyan" 
    GraphicsWindow.DrawBoundText (70150100, Clock.Time) 
    EndSub

  4. #4
    Join Date
    May 2008
    Posts
    176

    re: How to create analog clock using Small Basic

    Publish and share

    Small Basic now offers a very simple way to share programs with friends.

    Once your program is fully finished and completed, simply click "Publish."

    Your source code is then sent to a special server that stores all Microsoft programs that are submitted. Once the server has received your program it returns a code (a sort of reference number).

    You can then communicate this code to your friends.

    They can then click Import and enter the code you've provided so that they can automatically download the source code and run it on their own Small Basic.

    Note that the code can also be viewed online, simply by typing:
    http://smallbasic.com/program/?CODE
    Thus, to simply download the sample clock of the previous step without having to redo:
    - Start Small Basic
    - Click on the Import icon
    - Enter MLT668-1
    - Wait a few seconds the download code in a new window.

    This publication is very convenient to share programs and discover the products of other enthusiasts Small Basic.

    Some examples of emergency to discover:

    - Play LIGHTS OUT DanAwesome: VDK353
    - Super Pong: MDJ923
    - Bricks: QRQ360

Similar Threads

  1. Replies: 2
    Last Post: 07-08-2010, 06:05 AM
  2. How to create Windows DLL with Visual Basic?
    By Flaco in forum Software Development
    Replies: 4
    Last Post: 27-02-2010, 04:39 AM
  3. Create A Clock With Javascript
    By Sheenas in forum Software Development
    Replies: 5
    Last Post: 20-01-2010, 02:48 PM
  4. Create ActiveX dll with Visual Basic
    By B_Hodge in forum Software Development
    Replies: 2
    Last Post: 08-05-2009, 10:28 PM
  5. How to create an .exe file in visual basic
    By kasha_i in forum Software Development
    Replies: 3
    Last Post: 21-04-2009, 11:53 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,483,384.66954 seconds with 17 queries