Go Back   TechArena Community > ARENA > Guides & Tutorials
Become a Member!
Forgot your username/password?
Register Tags Active Topics RSS Search Mark Forums Read

Sponsored Links



How to create analog clock using Small Basic

Guides & Tutorials


Reply
 
Thread Tools Search this Thread
  #1  
Old 21-04-2009
Member
 
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.

Reply With Quote
  #2  
Old 21-04-2009
Member
 
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 ()
Reply With Quote
  #3  
Old 21-04-2009
Member
 
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
Reply With Quote
  #4  
Old 21-04-2009
Member
 
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.

Quote:
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
Reply With Quote
Reply

  TechArena Community > ARENA > Guides & Tutorials
Tags: , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "How to create analog clock using Small Basic"
Thread Thread Starter Forum Replies Last Post
Create a clock in Silverlight using Expression Blend or Visual Studio The$Hulk Guides & Tutorials 2 07-08-2010 06:05 AM
How to create Windows DLL with Visual Basic? Flaco Software Development 4 27-02-2010 03:39 AM
Create A Clock With Javascript Sheenas Software Development 5 20-01-2010 01:48 PM
Create ActiveX dll with Visual Basic B_Hodge Software Development 2 08-05-2009 10:28 PM
How to create an .exe file in visual basic kasha_i Software Development 3 21-04-2009 11:53 PM


All times are GMT +5.5. The time now is 10:29 AM.