We would like to build a community for Small Basic programmers of any age who like to code. Everyone from total beginner to guru is welcome. Click here to register and share your programming journey!


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Small Basic AI Championship
#41
(translated by Google translator)

Hi all.
For more than a week I wrote the code for the prototype of the "Nature" program. Here is the program number: PJBJ480.000
I only had 40...80 minutes a day. But this has become real entertainment from the moment Aliases appeared in SB-Prime.  Smile
During the creation of this prototype, I was getting used to the updated SB-Prime and the LD library.
Surprisingly, using SB-Prime, I like to create code even for things that no one will need. For many years of my life I could not do this. This brought back the joy of creativity to me, because programming gives you the opportunity to create different things without spending money on materials.

In the current version of my prototype, I'm modeling a way to inform the user about the state of the Server's Connection with two Clients.
The Connection and Disconnection events of clients are simulated using two CheckBox controls.
Switching the Server on and off is done using its switch.
I will be grateful for any tips and comments on the algorithm, design and code format.

And now I want to learn how to create "tooltips".
Thanks for attention.
Reply
#42
AB,

Good work so far - it works and looks good.  The structure is good with subroutines, meaningful variable names, comments, event loop.  Only suggestion is to maybe not do so much work with ShapeEvents where a simple button or other LDControl would work.  Also may not need so much pause and resume updates unless there is a bad flicker.

So its pretty good, but maybe a little over complicated.
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply
#43
LitDev,
I'll take your tips and test it out.
Thank you.

I am sure that I will not be the only person on the planet who will enjoy using SB-Prime.  Smile
Aliases provide incredible freedom for a person to communicate with a computer.
Reply
#44
(translated by Google translator)

Already at night, when I was already falling asleep, I asked myself which way was better to use in the "Nature" program:
1. infinite loop "While";
2. or only a reaction to an events ?  Huh

If I only use reactions to events, then in Small BASIC is it better to call one Timer tick or execute the entire reaction code in the event handler subroutine?
( but it is known that the handler subroutine must have a minimum code size )
Reply
#45
AB,

I always advocate the game loop, but experimentation is fun so try different things.

Reasons:

1] For complex event driven fast moving games, all the action takes place in one ordered loop - much easier to debug
2] Events can occur at any time and may also be running at the same time using the same variables - chaos
3] The main UI thread may not be updated while running in an event thread
4] If events keep coming faster than they take to complete they can stack up

Compare these 2 programs

Code:
ball = Shapes.AddEllipse(20,20)
GraphicsWindow.MouseMove = OnMouseMove

Sub OnMouseMove
  x = GraphicsWindow.MouseX
  y = GraphicsWindow.MouseY
  Shapes.Animate(ball,x-10,y-10,100)
  Program.Delay(100)
EndSub

Code:
ball = Shapes.AddEllipse(20,20)
GraphicsWindow.MouseMove = OnMouseMove

While("True")
  If (mouseMove) Then
    x = GraphicsWindow.MouseX
    y = GraphicsWindow.MouseY
    Shapes.Animate(ball,x-10,y-10,100)
    Program.Delay(100)
    mouseMove = ""
  EndIf
EndWhile

Sub OnMouseMove
  mouseMove = "True"
EndSub

When there are multiple events, potentially firing at the same time using the same variables it can get complicated, so I think the game loop makes things simpler, even though for a very small program it looks like added complexity.  There are cases where it doesn't really matter - like button presses.

Main thing is try it out whatever way you like and be prepared to change - I tend to write little prototypes to test ideas out.
[-] The following 2 users Like litdev's post:
  • AbsoluteBeginner, WhTurner
Reply
#46
(translated by Google translator)

LitDev,
thank you so much.
This information is very helpful to me.
So, with this information and the help you gave me in your previous message, I begin the next step towards creating the "Nature" program.  Wink
Reply
#47
(translated by Google translator)

Hi all.
Please tell me how to create a tooltip using Small Basic and the libraries that are available in SB-Prime?
So far I've only come up with the idea of using a shape with text.  Rolleyes

Thank you.
Reply
#48
AB,

Search with Tools->Search Extensions in SB-Prime.  We have one in IO and LD - should also work with Russian LitDev.Ru.xml translataion since it is the method name not the description.
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply
#49
(translated by Google translator)

Wow! Cool !
I didn't know about this Search.  Blush
When I manually searched  in the LD library, I didn’t think to search in Dialogs.

Thanks a lot.
Reply
#50
Hii AB
I Added Some ToolTips You Can View Its In LDDialog.ToolTip
Program ID : PJBJ480.000-0
Smile
Guess like working on project from sometime.
ZS
[-] The following 2 users Like z-s's post:
  • AbsoluteBeginner, Scout
Reply


Forum Jump:


Users browsing this thread: 11 Guest(s)