Physics and random scoring (Galton Box)

(Nick ) #1

I have been working with Physics quite a bit with this beta and also curious on how Hype 3 could be used for simple to more complex games.
In one of the threads some folks have been trying to come up with a hit/test scoring script with some limited success. I have started looking at a more antiquated method of scoring based on the randomness of the element physics.

First test is based on a Galton Box or Bean machine where balls are routed using alternate rows of pins to change their direction.
This could be a way to create some random chance games with Hype and the physics element either with gravity on the positive (drop) side or negative (float) side.
If javascript could be applied to the collection bins that might add for a more interesting way to display scores as well. (70.1 KB)

Is there a Physics API? 🤔
Call out to Educators using Hype to create physics animations
Physics: Redefine the edges of an element
(Greg) #2

Good to see you again Nick. You could use jQuery’s ‘offset’ to get the position of a ball then do a few if statements to see if the ball lies within one of the scoring areas. You could use regular javascript too, but jQuery makes it a lot easier.

Here’s a sample of getting a balls offset (I reduced the number of balls to simplify it) (69.5 KB)

(Nick ) #3

Greg, Thanks for this.
I think this has some possibilities. I noticed that since I have the balls turned up on their bounce and their friction it also effects their place in the offset over time.
If you click the button to test the offset over and over you can see how the ball moves a pixel every second and changes the outcome.
Tiny but a neat observation on how the Dynamic Physics interacts with the static physics elements.
I am going to do an update to the box this week and repost with some sliders to adjust physics on the balls as well.

(Greg) #4

Here’s a test with scoring for three balls. I still need to figure out a way to score two balls of the same color.

There is probably a much better way, but it’s fun learning :smiley:

Galton_Box_Edit3 (71.4 KB)

(kerguelen) #5

Hey Greg
Why do you write
all = (sc11)+(sc21)+(sc3*1)
all = (sc1)+(sc2)+(sc3)
be enough ?

(kerguelen) #6

Oh, and there seem to be a problem
Here’s what shows the box when I click Button :

(Greg) #7

I tried as you suggested but it would just put the numbers in the box like 1 2 3 instead of 6, so I used the multiplier to get past that. You’ll get the NaN (Not a Number) error if you hit the button before the balls hit the bottom of the game area because I’m also checking the top offset of the balls.

(Nick ) #8

Ok a new use for physics and quick digital toys.
This is a very simple all Hype feature little animated toy.
The characters have on Drag applied to them and physics.

  1. You drag a character to the top of the hill and drop him on the red dot.
  2. Click on the character to start the animation

Physics takes over the character as he sails off the hill.
The hill is overlaid with invisible shapes set to static physics to simulate the terrain.
If you adjust the friction and drag on the static and the dynamic elements you can get some nice effects.

After you have dragged all of the characters to the top and sent them sailing click the replay flag to start again.
saucersled (764.9 KB)

Is there a Physics API? 🤔
(Nick ) #9

Challenge: with this topic it would be neat to extend the play for the "sledders"
avoid flapping birds or snowmen etc.

1 thing that I learned with this exercise is that if you adjust friction on both your invisible terrain pieces and your sprite you can get a great sliding surface.

adding controls in a game on screen to adjust the physics in game play will be fun and that can be accomplished by creating slider for the physics properties.

Also used web fonts in this one too.

Another interesting thing is that you can do quite a bit with Hype Drag actions and Physics without adding a lot of javascript. The jQuery makes things more interesting for sure, but a designer can get a lot done with this new version.

(Jonathan Deutsch) #10

That’s a fantastically fun document @nick! I love the screams :).

(Nick ) #11


Thought I would share something that I found through a tweet.
Not Hype but Edge Animate.
This is a good example of a scoring mechanism.
I would be willing to pay extra for this as a quick function plug in for hype.
The rapid development of Hype based games would explode…positiviely of course :slight_smile: