sticky
Challenge of the Month - January 2019

    General discussion

  • These challenges are intended for people who are learning to program for the first time or for those returning to programming who want to start using Small Basic.  Some will be easy, some will be hard - but they will all make you think, and more importantly be GREAT FUN!

    Please post your solutions / partial solutions / questions / feedback etc. into this thread that will remain 'sticky' for the month.  The only rule is that your solution must use standard Small Basic methods (no extensions).

    It would be good if people could post their problems with these challenges so that a discussion can start so that everyone can learn from each other.

    Graphics Challenge

    • Draw a picture of a space ship
    • Give it a cool space starry background
    • Draw the phases of the moon

    What's your moon phase personality? | Wishing Moon

    Turtle Challenge

    Use the Turtle to draw a coloured 'tartan' checked pattern

    Use different pen widths and transparency and maybe the same repeating pattern vertcally and horizontally using subroutines

    Farquharson Ancient Medium Weight Tartan Fabric ...

    Geometry Challenges

    • Write a program to draw a pentagon
    • Write a program to draw a 5 pointed star
    • Write a program to draw a cog
    • Write a program to draw a cog wheel that rotates
    • Write a program with two meshed cogs that turn
    • Finally, white a program with 3 or more meshed rotating cogs

    Silhouette Gears On A White Background Stock Footage Video ...

    GUI Challenge

    White an interface with buttons to move backwards and forwards through a list of options. 

    Each time the an option is selected new options are presented from the list.

    The list could be anything, perhaps the colours of the rainbow.

    Add an image or description of the currently selected item.

    Try using partially transparent buttons covering textboxes to change the buttons' text.

    Do you have an idea or a future challenge? Please post it here!

    Wednesday, January 2, 2019 11:56 AM
    Moderator

All replies

  • mahreen miangul Duck Shoot ID VLP541 i have made this program with small basic forum help but the ducks are moving in one direction and not turning around but are coming back in backward direction need some help, and i wont the challenge of the month JanUary 2019 to be sprite drawning and then move them on the screen in diffrent directions. 1 sprites should be drawn and not loaded from the net. and 2 should be sprite shapes not maths figures ellipses triangles, rectangles

                                                                                                                                   mahreen miangul

    Wednesday, January 2, 2019 2:48 PM
  • I had a go at the Turtle challenge, but couldn't find a way to draw transparency with the Turtle... so I used shapes instead.

    ZNS517


    • Edited by Schmical Friday, January 4, 2019 1:44 AM
    Friday, January 4, 2019 1:44 AM
  • This is my first step for the geometry challenge: WDM914.

    Screen shot of a program Cog 0.1


    Nonki Takahashi


    Friday, January 4, 2019 5:32 AM
    Moderator
  • mahreen miangul Duck Shoot ID VLP541 i have made this program with small basic forum help but the ducks are moving in one direction and not turning around but are coming back in backward direction need some help, and i wont the challenge of the month JanUary 2019 to be sprite drawning and then move them on the screen in diffrent directions. 1 sprites should be drawn and not loaded from the net. and 2 should be sprite shapes not maths figures ellipses triangles, rectangles

                                                                                                                                   mahreen miangul


    Hi mahreen, I tried to flip shapes horizontally: VLP541-0

    Nonki Takahashi

    Friday, January 4, 2019 10:16 AM
    Moderator
  • I had a go at the Turtle challenge, but couldn't find a way to draw transparency with the Turtle... so I used shapes instead.

    ZNS517


    Hi Schmical, you can use transparent color like this:

    gw = 598
    gh = 428
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    GraphicsWindow.PenColor = "#300000FF"
    GraphicsWindow.PenWidth = 80
    tx = Turtle.X
    ty = Turtle.Y
    Turtle.Speed = 9
    ' horizontal pattern
    Turtle.PenUp()
    Turtle.Move(ty - 40)
    Turtle.TurnLeft()
    Turtle.Move(tx)
    Turtle.Turn(180)
    Turtle.PenDown()
    Turtle.Move(gw)
    ' vertical pattern
    Turtle.PenUp()
    Turtle.Turn(180)
    Turtle.Move(gw - 40)
    Turtle.TurnRight()
    Turtle.Move(40)
    Turtle.Turn(180)
    Turtle.PenDown()
    Turtle.Move(gh)


    Nonki Takahashi


    Friday, January 4, 2019 10:50 AM
    Moderator
  • VLP541-0 a very good Tutorial Thank you. The duck when hit should say somethig by mouth and also some written should come on screen. just some thing done in Euroa Duck hunt Game.

                                                                                                                   mahreen miangul

    Friday, January 4, 2019 3:14 PM
  • I had a go at the Turtle challenge, but couldn't find a way to draw transparency with the Turtle... so I used shapes instead.

    ZNS517


    Hi Schmical, you can use transparent color like this:

    gw = 598
    gh = 428
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    GraphicsWindow.PenColor = "#300000FF"
    GraphicsWindow.PenWidth = 80
    tx = Turtle.X
    ty = Turtle.Y
    Turtle.Speed = 9
    ' horizontal pattern
    Turtle.PenUp()
    Turtle.Move(ty - 40)
    Turtle.TurnLeft()
    Turtle.Move(tx)
    Turtle.Turn(180)
    Turtle.PenDown()
    Turtle.Move(gw)
    ' vertical pattern
    Turtle.PenUp()
    Turtle.Turn(180)
    Turtle.Move(gw - 40)
    Turtle.TurnRight()
    Turtle.Move(40)
    Turtle.Turn(180)
    Turtle.PenDown()
    Turtle.Move(gh)


    Nonki Takahashi


    Thanks Nonki, that's exactly what I needed.  I had no idea that you could use an 8 digit hex code for transparency+colour.

    Here's my updated program: BGB849

    The pattern itself can be modified by adjusting the array, I've also added a scaling option.

    Friday, January 4, 2019 10:14 PM
  • This is my graphics challenge "Draw a picture of a space ship": RWN229-0.

    Screen shot of a program Space and Rocket 0.2


    Nonki Takahashi


    Saturday, January 5, 2019 5:58 AM
    Moderator
  • This is my solution for the turtle challenge: GDD223.

    Screen shot of a program Turtle Tartan

    I used a fake because the Turtle is too slow.


    Nonki Takahashi

    Saturday, January 5, 2019 10:49 AM
    Moderator
  • sb-online hatch: BNF652

    Sunday, January 6, 2019 8:32 PM
  • This is my graphics challenge "Draw a picture of a space ship": RWN229-0.

    Screen shot of a program Space and Rocket 0.2


    Nonki Takahashi


    updated: JJV916

    • added animation flying stars
    • reduced to 250 lines
    • ld xtension required
    Monday, January 7, 2019 5:25 AM
  • I had a go at the Turtle challenge, but couldn't find a way to draw transparency with the Turtle... so I used shapes instead.

    ZNS517


    Hi Schmical, you can use transparent color like this:

    gw = 598
    gh = 428
    GraphicsWindow.Width = gw
    GraphicsWindow.Height = gh
    GraphicsWindow.PenColor = "#300000FF"
    GraphicsWindow.PenWidth = 80
    tx = Turtle.X
    ty = Turtle.Y
    Turtle.Speed = 9
    ' horizontal pattern
    Turtle.PenUp()
    Turtle.Move(ty - 40)
    Turtle.TurnLeft()
    Turtle.Move(tx)
    Turtle.Turn(180)
    Turtle.PenDown()
    Turtle.Move(gw)
    ' vertical pattern
    Turtle.PenUp()
    Turtle.Turn(180)
    Turtle.Move(gw - 40)
    Turtle.TurnRight()
    Turtle.Move(40)
    Turtle.Turn(180)
    Turtle.PenDown()
    Turtle.Move(gh)


    Nonki Takahashi


    Thanks Nonki, that's exactly what I needed.  I had no idea that you could use an 8 digit hex code for transparency+colour.

    Here's my updated program: BGB849

    The pattern itself can be modified by adjusting the array, I've also added a scaling option.

    converted for sb online: zfn115

    sb online has some issues with transparencies so it must be removed for now...



    • Edited by Tryhest Monday, January 7, 2019 6:02 AM
    Monday, January 7, 2019 6:01 AM
  • nonki made a nice pdf of drawing shapes in sb:

    congrats to nonki!

    link:pdf shapes


    • Edited by Tryhest Monday, January 7, 2019 6:18 AM
    Monday, January 7, 2019 6:15 AM
  • This is for geometry challenge- pentagon

    https://smallbasic-publicwebsite.azurewebsites.net/Program/view.aspx?FMB332

    Tuesday, January 8, 2019 1:44 PM
  • This is my second step for the geometry challenge: WDM914-0.

    Screen shot of a program Cog 0.2


    Nonki Takahashi

    Wednesday, January 9, 2019 9:37 AM
    Moderator
  • congrats for 40000+ pts nonki)!
    Wednesday, January 9, 2019 8:14 PM
  • This is my second step for the geometry challenge: WDM914-0.

    Screen shot of a program Cog 0.2


    Nonki Takahashi

    updated for 2 cogs: ZDH755


    note the optical moving illusion while watching this pict.
    • Edited by Tryhest Thursday, January 10, 2019 5:54 AM
    Thursday, January 10, 2019 5:53 AM
  • evolution algorithm: SRN536

    Friday, January 11, 2019 6:52 AM
  • some beaches of my hometown slideshow

    (for sb desktop only with ld xtension)

    pp=ldtext.split("zel ver1 ver svj1 st4 st3 st1 st ha3 ambr go ha ha1 ob001 ob002 ob003 ob004 st2222" " ")
    hh="http://pulskasvakodnevnica.com/wp-content/uploads/2016/09/"
    GraphicsWindow.Title="Beaches&Seaside of Pula * Istra * Croatia(HR)"
    While 1=1
      For f=1 To Array.GetItemCount(pp)
        ii=ImageList.LoadImage(hh+pp[f]+".jpg")
        LDGraphicsWindow.BackgroundImage(ii)
        Program.Delay(2222)
      EndFor
    EndWhile


    • Edited by Tryhest Friday, January 11, 2019 2:55 PM
    Friday, January 11, 2019 2:54 PM
  • 5 method to draw SB circles:

    1. Bresenham's line algorithm
    2. drawellipse
    3. sin/cos method
    4. turtle circle
    5. shapes ellipse

    Args=0
    cdrw="drawcircle"
    
    sub drawcircle'(int x0, int y0, int radius)------method 1
      x0=Args[1]
      y0=Args[2]
      radius=Args[3]
          x = radius-1 
          y = 0 
          dx = 1 
          dy = 1 
          err = dx - (radius *2) 
    
        while (x >= y)
             GraphicsWindow.SetPixel(x0 + x, y0 + y "red") 
             GraphicsWindow.SetPixel(x0 + y, y0 + x "red") 
             GraphicsWindow.SetPixel(x0 - y, y0 + x "red") 
             GraphicsWindow.SetPixel(x0 - x, y0 + y "red") 
             GraphicsWindow.SetPixel(x0 - x, y0 - y "red") 
             GraphicsWindow.SetPixel(x0 - y, y0 - x "red") 
             GraphicsWindow.SetPixel(x0 + y, y0 - x "red") 
             GraphicsWindow.SetPixel(x0 + x, y0 - y "red") 
    
            if (err <= 0) then
                y=y+1
                err = err+dy 
                dy = dy+ 2 
            
            elseif (err > 0) then
                x=x-1
                dx =dx+ 2 
                err = err+dx - (radius *2) 
            endif
        EndWhile
    EndSub
    
    GraphicsWindow.Title="circdrw"
    LDCall.Function3 (cdrw 100 100 40)
    GraphicsWindow.PenColor="red"
    GraphicsWindow.PenWidth=1
    GraphicsWindow.DrawEllipse(120 60 80 80)'-------method 2
    
    for r=0 to 360 step .5'-------------------------method 3
      cc=LDMath.Convert2Cartesian(200 100 40 r)
      GraphicsWindow.SetPixel(cc[1] cc[2] "red")
    EndFor
    
    Turtle.Speed=9
    Turtle.x=250 
    Turtle.y=60
    Turtle.Angle=90
    for x=90 to 450'--------------------------------method 4
      Turtle.Move(.7)
      Turtle.Angle=x
    EndFor
    
    GraphicsWindow.BrushColor="transparent"
    ee=Shapes.AddEllipse(80 80)'--------------------method 5
    Shapes.Move(ee 260 60)


    variations: PVC738
    • Edited by Tryhest Friday, January 11, 2019 9:10 PM
    Friday, January 11, 2019 8:19 PM
  • This is my third step for the geometry challenge: WDM914-1.

    Screen shot of a program Cog 0.3


    Nonki Takahashi

    Saturday, January 12, 2019 4:47 AM
    Moderator
  • antialiasing line draw: FVV103

    Saturday, January 12, 2019 5:56 AM
  • This is my third step for the geometry challenge: WDM914-1.

    Screen shot of a program Cog 0.3


    Nonki Takahashi

    nice done nonki!

    added 3d effect to cogs: RRQ220

    Saturday, January 12, 2019 7:39 AM
  • Pula slideshow(45 pics & description): DRM080

    (ld xtension needed)

    Sunday, January 13, 2019 7:30 AM
  • I completed the Space Ship Graphics Challenge, here is my Program ID: SLF871
    Tuesday, January 15, 2019 11:49 AM
  • describes some of basic dialects: BCD026

    Tuesday, January 15, 2019 10:41 PM
  • Program ID: GQM958

    I had an issue with my first attempt at the Space Ship Graphics Challenge. I used shapes to draw the outline of the space ship, but struggled to find a way to cover/hide part of the outlines of the shapes that overlapped the other shapes within the body of the space ship.

    My attempt to cover one of the lines is in Lines: 27 through to 36, but it just didn't quite work.
    Does anyone have any suggestions on how I could do this better please?

    Wednesday, January 16, 2019 7:44 AM
  • zebra riddle: KVM169

    Wednesday, January 16, 2019 2:20 PM
  • Program ID: GQM958

    I had an issue with my first attempt at the Space Ship Graphics Challenge. I used shapes to draw the outline of the space ship, but struggled to find a way to cover/hide part of the outlines of the shapes that overlapped the other shapes within the body of the space ship.

    My attempt to cover one of the lines is in Lines: 27 through to 36, but it just didn't quite work.
    Does anyone have any suggestions on how I could do this better please?

    use ldshapes.addpolygon (ld xtension)

    poly is defined by array of  nodes(1..n:px,py)--> a[n][1]=px; a[n][2]=py

    to trace nodes manually use graphicwindow.mousex(y)

    or u can use my autotrace tool: : TDQ132

    • Edited by Tryhest Wednesday, January 16, 2019 3:05 PM
    Wednesday, January 16, 2019 2:56 PM
  • For Baker = 0 To 4
      For Cooper = 0 To 4
        For Fletcher = 0 To 4
          For Miller = 0 To 4
            For Smith = 0 To 4
              If  (Baker<>4 ) and  (Cooper<>0 ) and  (Miller>Cooper ) Then
                If  (Fletcher<>0 AND Fletcher<>4 ) and  (math.ABS(Smith-Fletcher)<>1 ) and  (math.ABS(Fletcher-Cooper)<>1 ) Then
                  If  (Baker<>Cooper AND Baker<>Fletcher AND Baker<>Miller AND Baker<>Smith AND Cooper<>Fletcher AND Cooper<>Miller AND Cooper<>Smith AND Fletcher<>Miller AND Fletcher<>Smith AND Miller<>Smith) Then
                    textwindow.writeline( "Baker lives on floor " + Baker)
                    textwindow.writeline( "Cooper lives on floor " + Cooper)
                    textwindow.writeline( "Fletcher lives on floor " + Fletcher)
                    textwindow.writeline( "Miller lives on floor " + Miller)
                    textwindow.writeline( "Smith lives on floor " + Smith)
                  EndIf
                EndIf
              EndIf
            EndFor ' Smith
          EndFor ' Miller
        EndFor ' Fletcher
      EndFor ' Cooper
    EndFor ' Baker


    The problem

    Baker, Cooper, Fletcher, Miller, and Smith live on different floors of an apartment house that contains only five floors.

    • Baker does not live on the top floor.
    • Cooper does not live on the bottom floor.
    • Fletcher does not live on either the top or the bottom floor.
    • Miller lives on a higher floor than does Cooper.
    • Smith does not live on a floor adjacent to Fletcher's.
    • Fletcher does not live on a floor adjacent to Cooper's.

    Where does everyone live?

    Wednesday, January 16, 2019 7:28 PM
  • I completed the Space Ship Graphics Challenge, here is my Program ID: SLF871

    iPotato, nice code and nice graphics.

    Screen shot of a program Space Ship SLF871


    Nonki Takahashi

    Wednesday, January 16, 2019 11:45 PM
    Moderator
  • Program ID: GQM958

    I had an issue with my first attempt at the Space Ship Graphics Challenge. I used shapes to draw the outline of the space ship, but struggled to find a way to cover/hide part of the outlines of the shapes that overlapped the other shapes within the body of the space ship.

    My attempt to cover one of the lines is in Lines: 27 through to 36, but it just didn't quite work.
    Does anyone have any suggestions on how I could do this better please?


    Hi iPotato, my suggestion is to add triangles without pen (use yellow pen or zero pen width) instead of lines.

    Nonki Takahashi

    Wednesday, January 16, 2019 11:58 PM
    Moderator
  • This is my solution for the graphics challenge "Draw the phases of the moon": GNF678-0.

    Screen shot of a program Moon


    Nonki Takahashi


    Thursday, January 17, 2019 4:14 AM
    Moderator
  • Hi Nonki, thanks so much for taking the time to look at the 3 Program ID's I've published so far, and thanks so much for posting the pictures on my behalf - I really wanted to post the pictures but couldn't so I really appreciate you doing it for me! xD
    _______________________________

    iPotato

    Thursday, January 17, 2019 8:30 AM
  • This is my solution for the graphics challenge "Draw the phases of the moon": GNF678.

    Screen shot of a program Moon


    Nonki Takahashi

    nice done nonki:

    some updates: CZM711

    • corrected moon rotation - makes DOC not COD appearance
    • added tree and earth
    • removed obsolette lines
    • some colors changed


    • Edited by Tryhest Thursday, January 17, 2019 8:48 AM
    Thursday, January 17, 2019 8:46 AM
  • This is my solution for the Turtle challenge "Draw a coloured 'tartan' checked pattern": XPF283

    To be honest, this challenge was a bit beyond my skill level, my husband wrote it with me, and it was a good learning experience.
    Also a shout out to Nonki for teaching me how to use transparent colours!

    If anyone has some easier challenges for next month! xD

    Thursday, January 17, 2019 11:58 AM
  • This is my solution for the Turtle challenge "Draw a coloured 'tartan' checked pattern": XPF283

    To be honest, this challenge was a bit beyond my skill level, my husband wrote it with me, and it was a good learning experience.
    Also a shout out to Nonki for teaching me how to use transparent colours!

    If anyone has some easier challenges for next month! xD

    almost stage-like)) great color selection!

    Thursday, January 17, 2019 4:35 PM

  • If anyone has some easier challenges for next month! xD

    Any suggestions from anyone welcome - its kind of hard thinking new challenges that aren't repeats - and its not always easy to judge level - some are meant to be harder using more features and coding skill than drawing pictures, although these do seem the most popular by replies.
    Thursday, January 17, 2019 7:12 PM
    Moderator
  • Hi Tryhest, Thanks for your comments, and wanted to say thanks so much for posting the picture of my Tartan Pattern!
    ____________

    iPotato

    Friday, January 18, 2019 2:01 AM
  • I'm not sure if my idea would be too easy for everyone else!!! But I was going to suggest maybe using the Show What You Learnt from each lesson in the Tutorials as some super easy challenges.
    _______________________

    iPotato

    Friday, January 18, 2019 2:04 AM
  • Program ID: GQM958

    I had an issue with my first attempt at the Space Ship Graphics Challenge. I used shapes to draw the outline of the space ship, but struggled to find a way to cover/hide part of the outlines of the shapes that overlapped the other shapes within the body of the space ship.

    My attempt to cover one of the lines is in Lines: 27 through to 36, but it just didn't quite work.
    Does anyone have any suggestions on how I could do this better please?


    Hi iPotato, my suggestion is to add triangles without pen (use yellow pen or zero pen width) instead of lines.

    Nonki Takahashi

    Thanks for your suggestion Nonki. With your help, I have now completed my first attempt at the Space Ship challenge. Here is my Program ID: GQV782

    I came across a bug with the yellow flame on line 167. If I increase the width from 16 to 28 it draws a red line inside the yellow one and I can't seem to debug why. So I've had to add the additional 2 lines of code on lines 169 and 170 to do the other half of the yellow line.

    22 hours 1 minutes ago
  • Here is my Space Ship!


    3 hours 35 minutes ago