Author Topic: Physics Lessons  (Read 51823 times)

0 Members and 4 Guests are viewing this topic.

Offline ruler501

  • Meep
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2475
  • Rating: +66/-9
  • Crazy Programmer
    • View Profile
Re: Physics Lessons
« Reply #60 on: February 03, 2011, 07:38:04 pm »
If launched at an angle it is more complex but It was explained to me so I don't think its as hard anymore. i still think there should be an article here for it though. I can't do it because I couldn't show sample code. I only know python and C++. these lessons are still applicable there which is why I'd like an article here
I currently don't do much, but I am a developer for a game you should totally try out called AssaultCube Reloaded download here https://assaultcuber.codeplex.com/
-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCM/CS/M/S d- s++: a---- C++ UL++ P+ L++ E---- W++ N o? K- w-- o? !M V?
PS+ PE+ Y+ PGP++ t 5? X R tv-- b+++ DI+ D+ G++ e- h! !r y

Offline squidgetx

  • Food.
  • CoT Emeritus
  • LV10 31337 u53r (Next: 2000)
  • *
  • Posts: 1881
  • Rating: +503/-17
  • rawr.
    • View Profile
Re: Physics Lessons
« Reply #61 on: February 03, 2011, 07:38:56 pm »
Builderboy: if you don't feel like it I could write one for you; I just explained it to ruler so I'm kinda in the mood lol ;)
edit: actually, it would probably be suitable as a small addition to the first post, about gravity...
« Last Edit: February 03, 2011, 07:41:04 pm by squidgetx »

Offline Calcaholic

  • LV1 Newcomer (Next: 20)
  • *
  • Posts: 13
  • Rating: +2/-0
    • View Profile
Re: Physics Lessons
« Reply #62 on: February 03, 2011, 08:02:04 pm »
Could'nt you express that angle simply as gradient and split this gradient into a X- and a Y-velocity; where the y-velocity would be affected by gravity, while the x-velocity wouldn't?

But I can imagine, that this is horribly unoptimized... ;)
« Last Edit: February 03, 2011, 08:02:32 pm by Calcaholic »

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Physics Lessons
« Reply #63 on: February 04, 2011, 12:32:15 am »
everyone has been going craxy over cellular automata recently, so i decided to make a quick little open-source demo to act as reference.

it most certainly isn't optimised (or even constructed in a matter which will allow particles to interact with one another beyond collisions), but it at least gets the idea across. ADA is the source. the controls are fairly straight-forward, involving nothing more than 2nd, alpha, and the arrow keys (and clear to quit).
« Last Edit: February 04, 2011, 01:32:40 am by shmibs »

Offline AngelFish

  • Is this my custom title?
  • Administrator
  • LV12 Extreme Poster (Next: 5000)
  • ************
  • Posts: 3242
  • Rating: +270/-27
  • I'm a Fishbot
    • View Profile
Re: Physics Lessons
« Reply #64 on: February 04, 2011, 12:34:16 am »
Now I'm forced to work on Powder. You know that right? :P

Good job otherwise.
« Last Edit: February 04, 2011, 12:34:39 am by Qwerty.55 »
∂²Ψ    -(2m(V(x)-E)Ψ
---  = -------------
∂x²        ℏ²Ψ

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Physics Lessons
« Reply #65 on: February 04, 2011, 03:07:52 am »
Nice shmibs. :D

Offline Michael_Lee

  • LV9 Veteran (Next: 1337)
  • *********
  • Posts: 1019
  • Rating: +124/-9
    • View Profile
Re: Physics Lessons
« Reply #66 on: February 04, 2011, 03:03:45 pm »
Nice.  I like how the flames eat at the walls.

@ Builderboy: A while back, it looks like you were planning on adding a tutorial on collision detection?  Are you still planning on adding that?
« Last Edit: February 04, 2011, 03:04:02 pm by Michael_Lee »
My website: Currently boring.

Projects:
Axe Interpreter
   > Core: Done
   > Memory: Need write code to add constants.
   > Graphics: Rewritten.  Needs to integrate sprites with constants.
   > IO: GetKey done.  Need to add mostly homescreen IO stuff.
Croquette:
   > Stomping bugs
   > Internet version: On hold until I can make my website less boring/broken.

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: Physics Lessons
« Reply #67 on: February 05, 2011, 06:10:55 pm »
Your tutorial is very interesting, but I fail to apply your phisic in my multiplayer game. I've 8 player maximum, each player got 4 bytes to him : X and Y position on tilemap, an other information and his velocity. So, the array to manipulate is :
Code: [Select]
{N*4+GDB0+A}N is actual player, and A is byte we want modify (1st, 2nd, 3rd or 4th).

Players take turns, but all must be attracted by gravity. M is total number of player. Here my bad code :
Code: [Select]
:Lbl G
:For(Θ,0,M)
:For(r3,0,{Θ*4+GDB0→r5+3}
:If sub(GN,5+{r5},4+{r5+1}+1)=0
{r5+1}+1→{r5+1}
:End
:End
:If sub(GN,5+{r5},4+{r5+1}+1)=0
:{r5+3}+A→{r5+3}
:Else
:0→{r5+3}
:End
:End
:Return
Subroutine GN extract byte from tilemap :
Code: [Select]
:Lbl GN
:r2*102+r1→r1
:{r1/2+D}→r2
:If r1^2
:r2^16
:Else
:r2/16
:End
:Return

Have you an idea ? ???

You understand that your physical system is very useful, especially for jumps. ;D
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline shmibs

  • しらす丼
  • Administrator
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2132
  • Rating: +281/-3
  • try to be ok, ok?
    • View Profile
    • shmibbles.me
Re: Physics Lessons
« Reply #68 on: February 07, 2011, 01:48:44 am »
i was in la for the weekend and got bored, so i decided to clean up that little demo a bit and make it look more professional. the flames are now slightly more realistic, particles are displayed in gray when the program is run on an SE, and there are ? particles? (i think they're killer bees... :P)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Physics Lessons
« Reply #69 on: February 07, 2011, 01:54:40 am »
Alright, first, can't quite figure out what sub GN is suposed to do..  what does variable D mean?  It isn't used anywhere else in the code you posted.

Second, why are you looping from 0 to your velocity? For(r3,0,{Θ*4+GDB0→r5+3}) I think you want to move your character forward 1 space and check for collision each time?  Problems are going to arise when your velocity becomes negative.  I recommend switching to x256 format, since you are working with physics, and I recommend just incrementing your characters position by their velocity.  If they collide with an object, move them back to where they were before, and reverse the velocity.


EDIT: WOW thats an amazing application of cellular automata!  Outstanding! 
« Last Edit: February 07, 2011, 01:59:37 am by Builderboy »

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: Physics Lessons
« Reply #70 on: February 07, 2011, 01:28:58 pm »
GN is not the problem, it return the good tile (D point appvars Data).
My problem is hard to explain (at least with my bad english), I want use your phisic in a multi-player game. How can I affect every players in same time I'm moving in a tilemap ?
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline DJ Omnimaga

  • Clacualters are teh gr33t
  • CoT Emeritus
  • LV15 Omnimagician (Next: --)
  • *
  • Posts: 55943
  • Rating: +3154/-232
  • CodeWalrus founder & retired Omnimaga founder
    • View Profile
    • Dream of Omnimaga Music
Re: Physics Lessons
« Reply #71 on: February 07, 2011, 01:57:31 pm »
Wow shmibs that is amazing! You should make a new thread about this. :)

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Physics Lessons
« Reply #72 on: February 07, 2011, 06:42:05 pm »
GN is not the problem, it return the good tile (D point appvars Data).
My problem is hard to explain (at least with my bad english), I want use your phisic in a multi-player game. How can I affect every players in same time I'm moving in a tilemap ?

Ah you mean you have a scrolling tilemap?

Offline kindermoumoute

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 836
  • Rating: +54/-3
    • View Profile
Re: Physics Lessons
« Reply #73 on: February 08, 2011, 03:50:52 am »
Yes, I would like to add phisic gravity in my worms game :
Spoiler For Spoiler:

You can found the code here : here (a little old)
So, my gravity was this :
Code: [Select]
:Lbl G
:For(?,0,M)
:If sub(GN,5+{?*3+GDB0},5+{?*3+GDB0+1})=0 and (getKey(4)=0
:{?*3+GDB0+1}+1?{?*3+GDB0+1}
:End
:End
:Return
Your phisic system could be usefull to do some jump like here :
Spoiler For Spoiler:
Projects :

Worms armageddon z80 :
- smoothscrolling Pixelmapping : 100%
- Map editor : 80%
- Game System : 0%

Tutoriel français sur l'Axe Parser
- 1ère partie : en ligne.
- 2ème partie : en ligne.
- 3ème partie : en ligne.
- 4ème partie : 10%
- Annexe : 100%

Offline Builderboy

  • Physics Guru
  • CoT Emeritus
  • LV13 Extreme Addict (Next: 9001)
  • *
  • Posts: 5673
  • Rating: +613/-9
  • Would you kindly?
    • View Profile
Re: Physics Lessons
« Reply #74 on: February 08, 2011, 11:17:44 am »
Well first off, if you want realistic pysics, you might want to consider switching to x256 format.  This is where every time you add 256 to your position variables, your character moves 1 pixel.  This will allow you to have more precision and possibly get the gravity effects you are looking for.

However, If you do not want to use x256 format and stick with what you have, you can try this simple physics piece of code:

Code: [Select]
:Lbl G
:Θ*3+GDB0->r5
:If {r5+3}>>-7
:{r5+3}+1->{r5+3}
:End
:
:{r5+1}+{r5+3}->{r5+1}
:While sub(GN,{r5}+5,{r5+1}+5
:If {r5+3}>>0
:{r5+1}-1->{r5+1}
:Else
:{r5+1}+1->{r5+1}
:End
:End
:
:If sub(GN,{r5}+5,{r5+1}+5)=0 && getKey(4)
:-7->{r5+3}
:End
:Return

This piece of code *should* give you some realistic gravity and jumping in your game