Car physics
-
- Enthusiast
- Posts: 203
- Joined: Sat Apr 26, 2003 6:33 pm
- Location: Spain
- Contact:
Car physics
Hi, i will make a car game for mobile phones on next months, after make some research i ported a simple source code to PB, i didn't interested really to study car physics. I made some weeks ago a port of a car physics example from a java source, it isn't perfect, it have a bug when you break the car, but it could be useful to the community:
Car Physics example: http://www.balrogsoftware.com/download/carphysics.zip
Car Physics example: http://www.balrogsoftware.com/download/carphysics.zip
I've been looking for some car physics too. Could you post where you found the original? Maybe there was some documentation or other info along with it?
The most likely way for the world to be destroyed, most experts agree, is by accident. That's where we come in; we're computer professionals. We cause accidents. (Nathaniel Borenstein)
http://www.wirednerd.com
http://www.wirednerd.com
-
- Enthusiast
- Posts: 203
- Joined: Sat Apr 26, 2003 6:33 pm
- Location: Spain
- Contact:
Great ! But i think you use the Marco Monster tutorial to do it, isn'it ?
the url is :http://home.planet.nl/~monstrous/tutcar.html
But to day it's offline. I search this tutorial since many day. ! If you found this document on your hardisk Pleeeeeeeeeease post it i think you will do lot of happy people !
best regards and excuse me for my bad english !
Thy
the url is :http://home.planet.nl/~monstrous/tutcar.html
But to day it's offline. I search this tutorial since many day. ! If you found this document on your hardisk Pleeeeeeeeeease post it i think you will do lot of happy people !
best regards and excuse me for my bad english !
Thy
Thanks to svgaman from the french forum !
if you want this tutorial
http://web.archive.org/web/200602200627 ... utcar.html
if you want this tutorial
http://web.archive.org/web/200602200627 ... utcar.html
-
- Enthusiast
- Posts: 203
- Joined: Sat Apr 26, 2003 6:33 pm
- Location: Spain
- Contact:
Hi, i know that i didn't post here since months, sorry for this offline stage, i'm working on a new company and i didn't have enough time for personal projects in PB, but i still use PB to test algorithms and small tools for web or game development. Here you will find a new version of simple car physics that works fine, i got the code from a Flash racing game, and i ported it to PB, this code is the previous stage for my racing game for mobile phones. You can use the graphic of the first example.
NOTE: I have edited the code, it had a bug when you try to go backwards.
NOTE: I have edited the code, it had a bug when you try to go backwards.
Code: Select all
InitSprite()
InitSprite3D()
InitKeyboard()
Procedure.f min(a.f, d.f)
If a < d
ProcedureReturn a
Else
ProcedureReturn d
EndIf
EndProcedure
Procedure.f max(a.f, d.f)
If a > d
ProcedureReturn a
Else
ProcedureReturn d
EndIf
EndProcedure
Procedure.f sign(a.f)
If a.f < 0
ProcedureReturn -1.0
Else
ProcedureReturn 1.0
EndIf
EndProcedure
Procedure.f adjust(v.f,threshold.f,maximum.f)
vx.f = 0
If (v <= threshold)
vx=(v/threshold)*1.0
Else
vx = 1
EndIf
ProcedureReturn vx
EndProcedure
Quit.b = #False
accel.f = 0.2 ; acceleration due To gas (up arrow)
steer.f = 0.08 ; steering tightness
steer_normal.f = 0.08 ; Default Steering
steer_handbrake.f = 0.099 ; Incremental increases For handbrakeys
steer_threshold.f = 4 ; Speed where steering at its most manouvreable
MINspd.f = -5 ; max reverse speed
MAXspd.f = 22 ; max speed on straightaway
MAXskiddisplay.f = 2 ; Display skids on slides till this value reached
MAXturnSpd.f = 10 ; maximum speed While turning
MaxTurnSkid.f = 18 ; Maximum speed in turn before skidding
deccel.f = 0.92 ; decelleration due To brakes (down arrow)
handbrake.f = 0.93 ; decelleration due To brakes (down arrow)
handbrake_traction.f = 20 ; Amount of slide For handbrake higher is more
drift.f = 0.98 ; deceleration after letting off gas
speed.f = 0 ; duuuh!
surface.f = 3 ; Tar = 10 gravel = 1 ice = 0.5
traction.f = 5 ; the higher the more slippery init value
traction_max.f = 1 ; Max Traction
Dim vector.f(1) ; vector of the direction of the car
bounceBack.f = 0.6 ; percent of speed when bounced back from hitting an obstacle
angle.f
collide = false ; Used To make sure car doesnt get stuck in collision checks
If OpenWindow(0, 0, 0, 640, 480, "Car Physics", #PB_Window_ScreenCentered|#PB_Window_SystemMenu)
OpenWindowedScreen(WindowID(0), 0, 0, 640, 480, 0, 0, 0)
LoadSprite(0, "car.bmp", #PB_Sprite_Texture)
CreateSprite3D(0, 0)
Repeat
WEvent = WindowEvent()
If WEvent = #PB_Event_CloseWindow
Quit = #True
EndIf
rotation = angle * 180 / #PI
ExamineKeyboard()
UP = KeyboardPushed(#PB_Key_Up) >> 7
DOWN = KeyboardPushed(#PB_Key_Down) >> 7
HAND = KeyboardPushed(#PB_Key_LeftControl) >> 7
LEFT = KeyboardPushed(#PB_Key_Left) >> 7
RIGHT = KeyboardPushed(#PB_Key_Right) >> 7
UD = UP - DOWN
LR = RIGHT - LEFT
If LR
angle + (LR*steer*adjust(Abs(speed),steer_threshold, MAXSpd))
EndIf
If UD = #False
speed * drift
ElseIf UD <> #False And HAND = #False
speed = Min(Max(speed+UD*accel,MINspd),MAXspd)
EndIf
If (Abs(speed) < accel/2)
speed = 0
EndIf
If HAND
speed * handbrake
If (speed > MAXskiddisplay)
steer = steer_handbrake
EndIf
traction = handbrake_traction/surface
Else
traction = Max(traction_max, Abs((speed-MAXturnSpd)/surface))
steer = steer_normal
EndIf
If (speed < 0 )
traction = 1.0
EndIf
xv.f = ((Cos(angle) * speed) - vector(0))/traction
yv.f = ((Sin(angle) * speed) - vector(1))/traction
vector(0) + xv.f
vector(1) + yv.f
track_x.f + vector(0)
track_y.f + vector(1)
StartDrawing(ScreenOutput())
DrawText(0, 0, "Car x: " + StrF(x))
DrawText(0, 20, "Car y: " + StrF(y))
DrawText(0, 60, "speed: "+ StrF(speed))
DrawText(0, 80, "angle: " + StrF(rotation))
StopDrawing()
Start3D()
RotateSprite3D(0, rotation + 275, 0)
DisplaySprite3D(0, track_x, track_y, 255)
Stop3D()
FlipBuffers()
ClearScreen(0)
Delay(30)
Until Quit = #True
CloseWindow(0)
EndIf
-
- Enthusiast
- Posts: 195
- Joined: Thu Nov 29, 2007 8:23 am
-
- 666
- Posts: 1033
- Joined: Mon Sep 01, 2003 2:33 pm
Removed original reply at mod's request (troll has been banned now)
Great job Balrog!!!! All of us here appreciate everything you have shared with the community. I have personally learned from you
Great job Balrog!!!! All of us here appreciate everything you have shared with the community. I have personally learned from you
Last edited by Heathen on Mon Dec 10, 2007 1:17 am, edited 2 times in total.
Troll alert (ie not Balrog but PurePWNRER!!)
I'm not the first to point fingers, although I know Berikco is lazy (he said so himself), Fred's in love with TheHoff (no other reason why he would let Hasslehof's image all over the board) and the rest of us is nuts (including me, although perhaps excluding TheFool and PsychoPantha as they both may qualify as either insane or utterly mad due to heavy machine code indulgence). However, in your case, mister PurePWNRER, I fear you are nothing but a troll.
I've done a quick search on your name for your posts, and if negativity is a virtue, you're lined up for the top spot in the next Nobel price.
(And yes, I can be negative as well, but at least I TRY not to let that get the better part of me.)
So, why not leave out the criticism and show this board your good side? You're scaring away the girls...
I'm not the first to point fingers, although I know Berikco is lazy (he said so himself), Fred's in love with TheHoff (no other reason why he would let Hasslehof's image all over the board) and the rest of us is nuts (including me, although perhaps excluding TheFool and PsychoPantha as they both may qualify as either insane or utterly mad due to heavy machine code indulgence). However, in your case, mister PurePWNRER, I fear you are nothing but a troll.
I've done a quick search on your name for your posts, and if negativity is a virtue, you're lined up for the top spot in the next Nobel price.
(And yes, I can be negative as well, but at least I TRY not to let that get the better part of me.)
So, why not leave out the criticism and show this board your good side? You're scaring away the girls...
Last edited by blueznl on Wed Dec 12, 2007 8:26 am, edited 1 time in total.
( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
I only see one dummy here, who goes very far over the line.PurePWNRER wrote:It still does, dummyNOTE: I have edited the code, it had a bug when you try to go backwards.
Following your abomination of "car physics" ( ie it's just a kid's hack, I don't see why would anyone call this physics in the first place )
You also like to use multiple nicks in this forum, witch is not appreciated.
Please stay away if this is all you can post!
Balrog coded incredible things, helped numerous of people here, only problem is he visits us not enough these days
-
- Enthusiast
- Posts: 195
- Joined: Thu Nov 29, 2007 8:23 am
- Psychophanta
- Addict
- Posts: 4997
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Lípetsk, Russian Federation
- Contact:
Re: Car physics
No available fileBalrogSoft wrote:Hi, i will make a car game for mobile phones on next months, after make some research i ported a simple source code to PB, i didn't interested really to study car physics. I made some weeks ago a port of a car physics example from a java source, it isn't perfect, it have a bug when you break the car, but it could be useful to the community:
Car Physics example: http://www.balrogsoftware.com/download/carphysics.zip
http://www.zeitgeistmovie.com
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
While world=business:world+mafia:Wend
Will never leave this forum until the absolute bugfree PB
Re: Car physics
It is available in the 'Internet Archive Wayback Machine'.Psychophanta wrote:No available fileBalrogSoft wrote:Hi, i will make a car game for mobile phones on next months, after make some research i ported a simple source code to PB, i didn't interested really to study car physics. I made some weeks ago a port of a car physics example from a java source, it isn't perfect, it have a bug when you break the car, but it could be useful to the community:
Car Physics example: http://www.balrogsoftware.com/download/carphysics.zip