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
Hi, can you give an import code for your code so far.
Reply
(08-25-2024, 06:44 PM)litdev Wrote: Hi, can you give an import code for your code so far.

Yes. This is the File "Retro Football v0_0110.sb", which is in the folder in my OneDrive cloud.
The link is indicated in the previous post.

https://1drv.ms/f/s!AnoSlTzMqlL6jNwEee_Q...g?e=fFbV38

Shy
Reply
(08-25-2024, 04:59 PM)AbsoluteBeginner Wrote: I'm interested to know if there is a better way to create the ball blur effect.

The way you have done it looks good, its simple and effective.
Reply
Thank you, LitDev.  Shy

Everyone can see that my work is progressing very slowly.
But, the wonderful SB-Prime, the incredibly simple Small Basic, the powerful LD library and the ability to use Diagrams give me the pleasure of creating programs even in my difficult living conditions.

Before there was such a good set of "tools" for easy recreational programming, I spent years bored, not knowing what kind of program I should create.
Now I don't care what to program Rolleyes .
I'm interested in trying to create any program.
And the libraries that you, dear LitDev, connected to SB-Prime, provide us with more and more opportunities.
Now my program will be able to SEE the screen.
Now we can play with neural networks.
We have a 2D engine and 3D tools.

This is incredible !
And thank you for that.
Reply
(translated by Google translator)

Hi all.  Shy
For several days after the massive shelling of our energy system, I was unable to do any programming.
I had to improve my emergency power system because I had never experienced such a long power outage before.
And now, I can again engage in my interesting entertainment.  Rolleyes

My work stopped when I couldn't easily create a mechanism for controlling football players using mouse movement.
I have only just begun my research into this problem. Of course, if I have to do all the research myself, I will do it.
But, since I want to create my “Retro Football” quickly, I ask you to tell me the principle of solving the problem of controlling football players, if you know.

Thank you.
Reply
Hi AB,

Sorry to hear about your power situation.

Using the physics engine, it controls the collisions and corresponding bounces.  If you just move an object (paddle) then the engine will sometimes miss the collision or handle it badly, since the engine was not in control of the movement - you effectively disregarded the physics in the engine and teleported the paddle, possibly on top of a moving ball that finds itself inside the paddle and connot rebound according to its physics.

For this reason we interact with moving objects by applying impulses and torques rather than setting their position and rotation.

If an object is heavy (dense) than it will rebound less than light objects hitting it - we can use this to for example prevent dynamic paddles from moving much when hit by a light ball.

There are also joint constraints that can be set to constrain the movement of dynamic objects.

Unfortunately, these approaches are not 'simple'.  

In reality, the simplest approach is to program the paddle ball interactions (bounces) directly without the physics engine, since the geometry is very simple and a bounce of a ball on vertical or horizontal surface just flips the sign of one component of the velocity (X or Y).

If you want to go the physics engine route, we will be talking about impulses, momentum changes and physics engine constraints.  See samples Example13 and Example13A as a starting point.

If you want to go the (probably easier for this case) bouncing ball approach, then consider this example (SFRT178.000) which is quite old but still shows ball baddle bouncing - I think there are also simple 'breakout' type samples.

In either case, I can help, but as you say you will do most the work.
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply
Thank you for your kind words, dear LitDev.  Blush

I started the "Retro Football" project by describing the physics of the ball's movement directly in code.
I am comfortable using the "Microsoft Surface" tablet. It is convenient for my tasks. But there is little speed here for Football.

I'm interested in trying to use everything that Small Basic and the LD extension can do. So I began to research the engine.
I have already tried to influence objects using the "Mouse". But, I did not achieve the desired result.

So, really, for now I can only hope for impulses.  Shy

I wish everyone the very best.
See you at the sports competitions !
Reply
Hi,

I would expect that 'direct' movement of the ball and paddles by updating their position and handling the 'simple' ball vs vertical-horizontal wall collisions should be faster than the physics engine - it does a lot more calculations handling general collisions with friction and rotations.

For simplicity (and speed) I would use the direct option.

For fun and trying new stuff I would use the physics engine.  In this case I would probably start by setting the paddles as very heavy dynamic objects.  Move them vertically using vertical impulses (google about impulses) - basically they are instantaneous change in momentum (like nudging with a hammer taps) which can be treated like setting the velocity.  Since the mass of the paddles are not infinite, they will react a bit to the ball, but this can be very small which can be corrected by very small position/rotation (teleport) corrections that do not adversly affect the engine physics.  It may also be possible to use joint constraints for the paddles that prevent certain movements, while allowing others (eg. vertical only movement).

Depending how you want to proceed, I can create a small sample code: (case 1 - to check performance on your tablet, or case 2 to consider paddle user control).
[-] The following 1 user Likes litdev's post:
  • AbsoluteBeginner
Reply
(translated by Google translator)

Hi all.  Shy

Yes, dear LitDev, I opened my previous version of the game, in which I did not use the Physics Engine, and launched it.
I realized that if I add a ball blur effect, it will turn out just as good as using the Engine.

Thanks for the tip.
I wish everyone a good day.  Smile
Reply
(translated by Google translator)

And here's another interesting question: "Is it possible to increase the speed of the game "Retro Football" if you use the "LDInline" tool?"  Huh
Reply


Forum Jump:


Users browsing this thread: 18 Guest(s)