# Visual Basic > Games and Graphics Programming > Game Demos >  VB: Construction Game [Source]

## jonask

It's not a game really, but I think it's fun to play around with so 
here it is anyways  :Stick Out Tongue: 

You can get it, as allways, under Visual Basic on my homepage:
*jonask.com* 
the name of the file is 
*stress_and_structure_simulation.zip*
Or Clicking Here

This program alows you to place points into a 2d world, and then 
connect these points with links. You can also add factor like 
gravity, and muscle movement to the links. When the simulation is
 run the links will atempt to retain their length, and if not stress is 
calculated.

This makes for a rather interesting physics simulation. You can 
construct all kinds of machines, structures and animations and 
test how they react under different forces. 

and so on, and so on with the sales pitch...

Credits should go to the good people at sodaplay for giving me 
the inspiration to make this =)

Anyhey, I found it to be a very interesting piece of code, and I 
really think it is worth having a look at.

----------


## kedaman

loads of fun  :Alien Frog:  I couldn't get my stickguy to stand no matter how i constructed him, could you add an option to set resistance between two links from a node, so that they will also try to retain angle?

----------


## Fox

www.sodaplay.com isn't it  :Wink:  However, well done

----------


## cyborg

Really nice!

----------


## jonask

Yeah, I know what your mean about locking angles between points. But if I were to add that it would mean rewriting most of the physics engine, pluss it would be a whole story with torque and frankly I'm not sure I can come up with a smart way to do that :P

But if anyone has an idea on how to do eighter of the following, I would REALLY appreciate if you shared it with us here =)

1. Locked angles
2. "solid" lines. Lines that vertixes cannot pass through

----------


## NoteMe

Was it ment to be flat when it hit the earth???....BTW I got an overflow when I did set the strech bar to zero.. :EEK!: .. :Big Grin:

----------


## Electroman

I liked it too but I maximised the window then put it back to restored and it crashed  :Big Grin:

----------


## jonask

Yeah, I see... MaxStress was calculated like this:
 MaxStress = SetVal(4) / SetMax
with no limitation... it's fixed now =) thanks for pointing it out

What did you mean by something beeing flat when it hit the ground?


---
I think I know what you meant, Electroman, about minimizing the app. it has to do whith the resizing of the picture box, i think  :Stick Out Tongue:  fixed it too now, thanks =)

----------


## NoteMe

In the version Fox showed us it kind of bounced when it hit the gorund, but in your app when it hits the ground it craches together and all the points land on the ground like a line...is that what is supposed to happen?

----------


## jonask

Well, that is one of the advantages of my model vs Sodaplay's.
In mine you can choose whether or not you want to follow the simpler sodaplay model or if you would like the links to snapp under stress, thus allowing for a "Bridge Builder/Pontifex" feeling =)

----------


## Electroman

> _Posted by jonask_ 
> *Well, that is one of the advantages of my model vs Sodaplay's.
> In mine you can choose whether or not you want to follow the simpler sodaplay model or if you would like the links to snapp under stress, thus allowing for a "Bridge Builder/Pontifex" feeling =)*


 hehe...yeah I saw that, I was pulling things about and they started to fall apart  :Big Grin: .

----------


## NoteMe

> _Originally posted by jonask_ 
> *Well, that is one of the advantages of my model vs Sodaplay's.
> In mine you can choose whether or not you want to follow the simpler sodaplay model or if you would like the links to snapp under stress, thus allowing for a "Bridge Builder/Pontifex" feeling =)*



Did you try this???

http://www.sodaplay.com/constructor/index.htm

Lift it up and let it fall to the ground...then see...it doesn't break...just bounces a bit..

----------


## jonask

yeah, yeah they do. Because the stress is to lagre due to the impact and stuff, and so they snap  =) But if you look under settings, you'll se you can turn that off.
I shouldve mentiond this before I guess  :Stick Out Tongue:

----------


## kedaman

For solid lines you would need to do a line/line collision detection between the solid line and the line that starts at the vertex in one frame and ends in same vertex in the next. The vertex would then have to bounce off at an "intermediate frame" which is not displayed, I guess thats how they do collisions in pool games.

Torque is radial force.. or is that tangential, dunno but I guess it must be stronger the further away you are from the vertex, so the radius must be in the equation

----------


## kedaman

Here's a nice tutorial btw:
http://www.physics.uoguelph.ca/tutor.../Q.torque.html

----------


## jonask

Thanks for the link =) I guess I'll dig up my old notes from physics class, load up that page and get crackin. Maybe I can get it to work, but i doubt it  :Stick Out Tongue: 
stay tuned

----------


## alkatran

BUG: Place a single point, and attach many many bars to it. Don't have them move or anything (do this while simulate is off)

Put about 20 bars attached to the one point. Click simluate or start or whatever it was.

Watch the big spiky thing go nuts and explode.

----------


## jonask

Haha, yeah, so it does.

I know why, approximation problems :/ no easy fix I can think of as for now, but I'll keep you posted =)

Thanks for letting me know!

----------


## alkatran

Also:
Build a starshape, with have two adjacent points being fixed (do this in simulation mode) (don't build the shape extremely large... medium to small sized)
Make sure every point is hooked to every other point
Set the stretch factor to max
Take adjacent fixed point #2 and place it at the position of fixed point #1.
The line between the two fixed will break, but the rest of the shape will  begin rotating around them!
I tested to make sure it was actually generating force by attaching certain shapes which would brush the wall (high friction, no bounce). The speed would go up to whatever value all the time.

----------


## jonask

I havn't tried it out, but i'm sure your right.
There are several 'flaws' that in the physics modell, and they are all related to the quantitative nature of the cumputer calculations... I can think of ways to correct some of the artifacts, but the code would be too extensive, and i feel that it would ruin some of the beauty in the simulation  :Stick Out Tongue:  E.i. if I were to add many if conditions, trying to control every one of these small misshaps it would contradict with the "one pure law" that I'm unsing.

I don't know it that came out right, but who's gonna care?  :Smilie:

----------


## alkatran

The rotating thing can make some weird effect... and the exploding point one is impossible to contain. I tried putting support against the walls.. but no luck.

----------

