Help us understand the problem. What is going on with this article?

smallbasic ゲームスレッド

More than 5 years have passed since last update.

サンプル

Sub setup
  paddle = Shapes.AddRectangle(120, 12)
  ball = Shapes.AddEllipse(16, 16)
  GraphicsWindow.FontSize = 14
  GraphicsWindow.MouseMove = OnMouseMove
  score = 0
  PrintScore()
  Sound.PlayBellRingAndWait()
  x = 0
  y = 0
  deltaX = 1
  deltaY = 2
EndSub

Sub loop
RunLoop:
  x = x + deltaX
  y = y + deltaY  
  gw = GraphicsWindow.Width
  gh = GraphicsWindow.Height
  If (x >= gw - 16 Or x <= 0) Then
    deltaX = -deltaX
  EndIf
  If (y <= 0) Then
    deltaY = -deltaY
  EndIf 
  padX = Shapes.GetLeft(paddle)
  If (y = gh - 28 And x >= padX And x <= padX + 120) Then
    Sound.PlayClick()
    score = score + 10
    PrintScore()
    deltaY = -deltaY
  EndIf
  Shapes.Move(ball, x, y)
  Program.Delay(5)  
  If (y < gh) Then
    Goto RunLoop
  EndIf  
  GraphicsWindow.ShowMessage("Your score is: " + score, "Paddle")
  Program.End()
EndSub

Sub OnMouseMove
  paddleX = GraphicsWindow.MouseX
  Shapes.Move(paddle, paddleX - 60, GraphicsWindow.Height - 12)
EndSub

Sub PrintScore
  GraphicsWindow.BrushColor = "White"
  GraphicsWindow.FillRectangle(10, 10, 200, 20)
  GraphicsWindow.BrushColor = "Black"
  GraphicsWindow.DrawText(10, 10, "Score: " + score)
EndSub

setup()
loop()
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした