Vai al contenuto

Challenge 2014-07

Small Challenges

  1. Write a program that moves a ball when the mouse is moved (the ball stays under the mouse).
  2. Extend the program above to leave a trail behind the moving ball.
  3. Write a TextWindow program to enter a date and then validate that it has the correct format (e.g. DD/MM/YYYY or MM/DD/YYYY).
    Make sure it handles leap years!
  4. Write a program to replace all spaces in some text with ‘_’.
  5. Write a program to create 5 buttons in a vertical column, when each is clicked it plays a different sound or musical note.
  6. Write a program to generate random letters (a-z).

Group Challenge

This challenge is to create an extensible ‘Paint’ program with plugins.

There are several paint type programs in Small Basic – they mostly consist of drawing on a window following a mouse when a mouse button is clicked and held down.

The idea of this challenge is:

  1. to write the main program in such a way that it is easy for people to add their plugins.
  2. to write fun plugins.

A plugin may be as simple as changing the line width or color, or more complicated like drawing stars or any other feature.

The plugins should:

  1. be a single subroutine.
  2. have a name that can be obtained from the plugin, so that it can be selected.
  3. either perform drawing actions when the mouse is moved while a mouse button is down or change some property.

Quite a bit of thought will be needed to design the program so that plugins can work well, be selectable etc.  Perhaps plugins need to also be added to a text file list of plug-ins?

Examples of plugins could be:

  1. Change brush color.
  2. Change pen thickness.
  3. Draw random colored stars as the mouse moves.
  4. Eraser.

The program itself should have only a very basic plugin example and it is up to other contributors to create their plug-ins meeting the required specification.

I recommend some discussion/collaboration of ideas before coding, perhaps start from the example in the ‘Introducing Small Basic’ guide.

GraphicsWindow.MouseMove = OnMouseMove
GraphicsWindow.MouseDown = OnMouseDown
Sub OnMouseDown
   prevX = GraphicsWindow.MouseX
   prevY = GraphicsWindow.MouseY
Sub OnMouseMove
   If(Mouse.IsLeftButtonDown) Then
      GraphicsWindow.DrawLine(prevX, prevY,  x, y)

Game Challenge

Write an ‘air hockey’ 2 player game.

Community Suggestions

by Athasak

  1. Make a unit converter.
    For example 1 kilogram is 1000 grams.
    So make a program to convert the kilogram to 1000 grams.
  2. Make a basic chat program (Example JDT558).
  3. Make a RGB (red – green – blue) menu with sliding bars that changes the background color (Example NHJ269).
  4. Make a “Scroll Down Bar”, you know… a bar that scrolls down some text or shapes or images (Example ZDP541).
  5. Make a program to change pages of text when you click and drag the page to the left edge of the window (in order to see the next page) and when you click and drag the page to the right edge of the window (in order to see the previous page).
    It may sound kinda confusing so here is an example SFR639.

by Nonki

  1. Create a international version of Hello World program.
  2. Create a program to show Small Basic source.
    Comment lines must be shown as green.
  3. Draw a picture of a regular triangle.

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

Questo sito usa Akismet per ridurre lo spam. Scopri come i tuoi dati vengono elaborati.