This week's featured sample of the week comes from mcleod_ideafix. This is a fun little point and shoot game, involving the Turtle in a clever way.

'Point-and-shoot

'(C)1989 McLeod/IdeaFix. http://www.zxprojects.com'Target size

TargetSize=30

winner=0

wanttoplay=1'A vector-screen style window

GraphicsWindow.BackgroundColor="Black"

GraphicsWindow.PenColor="Green"

GraphicsWindow.Clear()Game()

Sub Game

While (wanttoplay=1)

GetRnd()

DrawTarget()

Turtle.PenUp()'Game loop

While (winner=0)

Shoot()

EndWhilewinner=0

TextWindow.Write("Another game? (y/n) ")

answ = TextWindow.Read()

If (Text.StartsWith(Text.ConvertToLowerCase(answ),"n")) Then

wanttoplay=0

Else

GraphicsWindow.Clear()

Turtle.PenDown()

GraphicsWindow.PenColor="Green"

EndIf

EndWhile

EndSubSub Shoot

TextWindow.Write("Angle? ")

ang=TextWindow.ReadNumber()

TextWindow.Write("Distance? ")

dist=TextWindow.ReadNumber()Turtle.Turn(ang)

Turtle.Move(dist)

Turtle.Turn(-ang)xs=dist*Math.Cos(Math.GetRadians(ang))

ys=dist*Math.Sin(Math.GetRadians(ang))If (xs>=xmin And xs<=xmax And ys>=ymin And ys<=ymax) Then

Sound.PlayChimes()

Turtle.Speed=100

Turtle.Move(-15)

Turtle.PenDown()

'The boom! visual effect

For n=1 To 36

GraphicsWindow.PenColor=GraphicsWindow.GetRandomColor()

Turtle.Move(30)

Turtle.Turn(150)

EndFor

Turtle.PenUp()

Turtle.Move(15)

Turtle.Turn(ang)

Turtle.Move(-dist)

Turtle.Turn(-ang)

Turtle.Hide()

TextWindow.WriteLine("Target cleared!! You WIN")

winner=1

Else

TextWindow.Write("Target failed!! Try again (press RETURN)")

TextWindow.Read()

Turtle.Speed=100

Turtle.Turn(ang)

Turtle.Move(-dist)

Turtle.Turn(-ang)

Turtle.Speed=7

winner=0

EndIf

EndSubSub GetRnd

'These variables should store the current Height and Width of

'GraphicsWindow, but it seems not to work

he=480

wi=640If (he < wi) Then

distance=40+Math.GetRandomNumber(he/2-TargetSize-40)

Else

distance=40+Math.GetRandomNumber(wi/2-TargetSize-40)

EndIf

angle=Math.GetRandomNumber(360)xmin=distance*Math.Cos(Math.GetRadians(angle))

ymin=distance*Math.Sin(Math.GetRadians(angle))

xmax=xmin+TargetSize

ymax=ymin+TargetSize

EndSubSub DrawTarget

Turtle.Speed=100

Turtle.PenUp()

Turtle.Turn(angle)

Turtle.Move(distance)

Turtle.Turn(-angle)

Turtle.PenDown()

For n=1 To 4

Turtle.Move(TargetSize)

Turtle.TurnRight()

EndFor

Turtle.PenUp()

Turtle.Turn(angle)

Turtle.Move(-distance)

Turtle.Turn(-angle)

Turtle.PenDown()

Turtle.Speed=7

EndSub

And here's the screenshot.

Do you want your samples to be featured here? Post them in our forums and we'll pick one each week.

PingBack from http://mstechnews.info/2008/11/sample-of-the-week/

I like the idea of Small Basic, but we need a little more control.

Maybe I’m too used to Visual Studio, but the lack of right-click menus really makes me feel weird. 😐

Oops, I forgot to mention this program fails to run for me and it crashes small basic.

well personally this program tells me nufink and frankly i don't like it. Which means in the long run that i will fail my assignment and get an F!1whooo whoooh

p.s

Harry is lovely

Kindest Regards

Namfred:)