Using xLib, I wrote a pretty straightforward program that simulates an object floating in water. Not only does this object have bouyancy, but it also simulates the effect of surface tension.

In addition, I adapted my buoyancy code to create interesting permeable barriers that allow objects in, but quickly "bounce" them out. Such an effect could be easily applied to games in order to add variety to the composition of landscapes.
Very nicely done, rthprog! It's impressive either way, but did you use the actual equations for buoyancy and surface tension, or did you derive a "reasonable" approximation based on observation and trial and error?
KermMartian wrote:
Very nicely done, rthprog! It's impressive either way, but did you use the actual equations for buoyancy and surface tension, or did you derive a "reasonable" approximation based on observation and trial and error?
I imagine he wrote it himself, citing a <a href="http://twitter.com/rthprog/status/17050594984">twitter update</a>.
KermMartian wrote:
Very nicely done, rthprog! It's impressive either way, but did you use the actual equations for buoyancy and surface tension, or did you derive a "reasonable" approximation based on observation and trial and error?


Thanks Smile The latter; it's all done through logic statements, albeit fairly lengthy ones.
rthprog wrote:
KermMartian wrote:
Very nicely done, rthprog! It's impressive either way, but did you use the actual equations for buoyancy and surface tension, or did you derive a "reasonable" approximation based on observation and trial and error?


Thanks Smile The latter; it's all done through logic statements, albeit fairly lengthy ones.
Any interest in having the SourceCoder bot post up some code so that we can critique and optimize with you? Smile
Cool! It reminds me of Builderboy's Zed Physics Engine. He did something similar with buoyancy and supported other neat stuff too. Good job, I'm surprised you were able to pull it off with xLib.
quigibo wrote:
Cool! It reminds me of Builderboy's Zed Physics Engine. He did something similar with buoyancy and supported other neat stuff too. Good job, I'm surprised you were able to pull it off with xLib.
Good call, and nifty link there, I'll have to look at that Zedd engine a little more closely.
Looking great there, rthprog. Awesome program! Smile

I can think of quite a few different ways this could be applied to games Razz
swivelgames wrote:
Looking great there, rthprog. Awesome program! Smile

I can think of quite a few different ways this could be applied to games Razz
Definitely! Actually, I could see a couple of games being created almost directly from this demo without much modification. How about a game where things fly right over the water, right under the water, and fall into the water, and you have to avoid them all?
KermMartian wrote:
Any interest in having the SourceCoder bot post up some code so that we can critique and optimize with you? Smile


Of course!

Variables:
H= Horizontal Velocity
V= Vertical Velocity
S= Position along the x-axis
T= Position along the y-axis
K= keystroke

I often use S and T instead of X and Y because X and Y have a tendency to be overwritten.


Code:
:ClrDraw
:Text(1,1,"
:real(0,1
:real(12,8,0,0,7,7,0
:real(12,8,3,3,4,4,0
:real(12,8,0,0,0,0,0
:real(12,8,0,7,0,7,0
:real(12,8,7,0,7,0,0
:real(12,8,7,7,7,7,1
:For(N,1,8
:For(M,1,8
:If fPart(.5(N+M
:Pxl-On(N-1,M+7
:End
:End
:real(9,1,4
:real(9,0,4
:real(0,1
:real(12,0,0,30,94,30,1
:For(N,0,11
:For(M,0,5
:real(1,8N,8M+30,1,8,4,1,0,2,0,1
:End
:End
:Text(1,3,"AIR
:Text(56,3,"FLUID
:Pause
://For those of you who are new to xLib programming, don't do what I did above in anything other than a demo; it's a disgusting way to set up sprites and the background every time the program is run.  Below is the code that really matters.
 
:real(9,1,5
:real(9,0,5
:43→S
:5→T
:8→V
:3→H
:While 1
:real(3,5,0,0
:real(1,S,T,1,8,4,0,0,2,0,1

://Just so you know, the sprite is meant to slowly move towards the center of the horizontal axis. This way, losing it off screen is less of an issue for the video.
:H+1.5(H<0)-(H>0)+.8((S<46)-(S>46))→H

://This part is just an approximation, so any optimizations don't need to perform the exact same function.
:V-(T>26 and V>0)-(T>26)+3.4(T<26)+1.6((V<0)-(V>0))(abs(V)>3 and 3≥abs((T-26)→V
:iPart(S+H+(T>26)randInt(‾1,1)→S
:iPart(T+V→T
:getKey→K
:While K
:H+1.9((K=26)-(K=24→H
:V+2.1((K=34)-(K=25→V
:getKey→K
:End
:End


Quote:
How about a game where things fly right over the water, right under the water, and fall into the water, and you have to avoid them all?
Exactly; it could be done very easily. The only real issue would be to keep the game going at a speed adequate for TI83+s
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement