It is currently Mon Dec 11, 2017 5:05 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Car physics
PostPosted: Sat Jan 20, 2007 1:06 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 6:33 pm
Posts: 203
Location: Spain
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

_________________
Balrog Software
balrog@balrogsoftware.com
www.balrogsoftware.com


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Feb 04, 2007 3:22 am 
Offline
User
User

Joined: Tue May 09, 2006 8:43 pm
Posts: 55
Location: Faroe Islands
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


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Fri Feb 09, 2007 1:05 pm 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 6:33 pm
Posts: 203
Location: Spain
I don't have the url where i found the code, i have it on a old harddisk, i changed the harddisk of my notebook some weeks ago. I will try to find it this weekend.

_________________
Balrog Software
balrog@balrogsoftware.com
www.balrogsoftware.com


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Mar 27, 2007 9:30 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Dec 25, 2004 2:37 pm
Posts: 218
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 :P i think you will do lot of happy people !

best regards and excuse me for my bad english !

Thy


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Wed Mar 28, 2007 4:21 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sat Dec 25, 2004 2:37 pm
Posts: 218
Thanks to svgaman from the french forum !
if you want this tutorial
http://web.archive.org/web/20060220062712/http://home.planet.nl/~monstrous/tutcar.html :P


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Thu Oct 11, 2007 8:47 am 
Offline
Enthusiast
Enthusiast

Joined: Sat Apr 26, 2003 6:33 pm
Posts: 203
Location: Spain
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.

Code:
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

_________________
Balrog Software
balrog@balrogsoftware.com
www.balrogsoftware.com


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 09, 2007 2:56 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Nov 29, 2007 8:23 am
Posts: 195
.


Last edited by BriceManuel on Mon Dec 10, 2007 2:25 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 09, 2007 3:35 am 
Offline
666
666

Joined: Mon Sep 01, 2003 2:33 pm
Posts: 1033
Edited Per request


Last edited by LuCiFeR[SD] on Mon Dec 10, 2007 1:31 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 09, 2007 6:16 am 
Offline
Enthusiast
Enthusiast

Joined: Tue Sep 27, 2005 6:54 pm
Posts: 498
Location: At my pc coding..
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 :)


Last edited by Heathen on Mon Dec 10, 2007 1:17 am, edited 2 times in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 09, 2007 10:19 am 
Offline
PureBasic Expert
PureBasic Expert
User avatar

Joined: Sat May 17, 2003 11:31 am
Posts: 6032
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...

_________________
( PB5.50 Win7 x64 Dell XPS710 nForce 5 Intel Q6600 SSD Evo 840 GFX GTS450 )
( You have two options: psychotherapy, or the PureBasic Survival Guide... )


Last edited by blueznl on Wed Dec 12, 2007 8:26 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 09, 2007 7:05 pm 
Offline
Administrator
Administrator

Joined: Wed Apr 23, 2003 7:57 pm
Posts: 1315
Location: Belgium
PurePWNRER wrote:
Quote:
NOTE: I have edited the code, it had a bug when you try to go backwards.

It still does, dummy ;)

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 )

I only see one dummy here, who goes very far over the line.
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 :(

_________________
Berikco

http://www.vispluk.be


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Dec 09, 2007 7:34 pm 
Offline
Administrator
Administrator

Joined: Wed Apr 23, 2003 7:57 pm
Posts: 1315
Location: Belgium
blueznl wrote:
...although I know Berikco is lazy...


Just don't tell this to everybody will you! :wink:


So, removed the trol, everybody edit there message, so we can continue this useful thread.

_________________
Berikco

http://www.vispluk.be


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Dec 10, 2007 9:55 am 
Offline
Enthusiast
Enthusiast

Joined: Thu Nov 29, 2007 8:23 am
Posts: 195
edited message per your request.


Top
 Profile  
Reply with quote  
 Post subject: Re: Car physics
PostPosted: Sun Apr 24, 2016 1:47 am 
Offline
Addict
Addict
User avatar

Joined: Wed Jun 11, 2003 9:33 pm
Posts: 4386
Location: Spa, relaxing and thinking, and learning...
BalrogSoft 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


No available file :?

_________________
http://www.zeitgeistmovie.com

While world=business:world+mafia:Wend
While (world==business) {world+=mafia}


Top
 Profile  
Reply with quote  
 Post subject: Re: Car physics
PostPosted: Sun Apr 24, 2016 2:57 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jul 25, 2005 3:51 pm
Posts: 3425
Location: Utah, USA
Psychophanta wrote:
BalrogSoft 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


No available file :?


It is available in the 'Internet Archive Wayback Machine'. :wink:

_________________
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 21 posts ]  Go to page 1, 2  Next

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


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

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye