forums.ps2dev.org Forum Index forums.ps2dev.org
Homebrew PS2, PSP & PS3 Development Discussions
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

calculating too fast

 
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development
View previous topic :: View next topic  
Author Message
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Wed Oct 19, 2005 11:23 am    Post subject: calculating too fast Reply with quote

im making a drag racing game. i spent like an hour or 2 working out the equations for the gear ratios and what not. i based it off of data collected from gt4(playing the game is why it took me about 2 hours). anyway, i got it all worked out and it should go really good. in fact it pretty much does each gear works fairly good. problem is the game is too good at checking #s. i have my shifting set up as...

Code:
function shiftup()
gear = gear+1
end

function shiftdn()
gear = gear-1
end

....
if pad:r() then
shiftup() end
if pad:l() then
shiftdn() end


i also have a gear max and min setup but thats not important. the thing is as soon as i tap r itll keep going. one tap may shift to 2 or 6. is their any way to make some functions or just slow it down? i tried making a seperate function for every gear but that did the same thing.
Back to top
View user's profile Send private message
chaos



Joined: 10 Apr 2005
Posts: 135

PostPosted: Wed Oct 19, 2005 1:24 pm    Post subject: Reply with quote

Code:

upCount = 0
downCount = 0

function checkPad()
   local pad = Controls.read()
   
   if pad:up() then
      upCount = upCount + 1
      if upCount == 1 then
         shiftUp()
      end
   else
      upCount = 0
   end
 
   if pad:down() then
      downCount = downCount + 1
      if downCount == 1 then
         shiftDown()
      end
   else
      downCount = 0
   end
end


modify your code to only trigger once per button push.. like above.
_________________
Chaosmachine Studios: High Quality Homebrew.


Last edited by chaos on Thu Oct 20, 2005 10:38 pm; edited 1 time in total
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Wed Oct 19, 2005 6:58 pm    Post subject: Reply with quote

outch!
added the clean solution (by shine)
to the wiki here

greets
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Thu Oct 20, 2005 11:49 am    Post subject: Reply with quote

Code:
if upCount = 1 then

that part (and the downcount one) give me an error. it says then expected near =. i change it to
Code:
if upCount > 1 then 
that got rid of the error but it went back to what it was doing before.
thank you though.
Back to top
View user's profile Send private message
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Thu Oct 20, 2005 12:44 pm    Post subject: Reply with quote

nevermind...i changed it to
Code:
if upCount == 1 then

but i must have changed something in other parts of the code cause it doesnt work right.
Back to top
View user's profile Send private message
chaos



Joined: 10 Apr 2005
Posts: 135

PostPosted: Thu Oct 20, 2005 10:33 pm    Post subject: Reply with quote

ya, that was a fairly quick hack in notepad, not tested at all.. just a general idea. it should have been ==
_________________
Chaosmachine Studios: High Quality Homebrew.
Back to top
View user's profile Send private message
chaos



Joined: 10 Apr 2005
Posts: 135

PostPosted: Thu Oct 20, 2005 10:37 pm    Post subject: Reply with quote

LuMo wrote:
outch!
added the clean solution (by shine)
to the wiki here

greets


there are some problems with that method.. every time any control changes, it will re-read all controls being held, as if you pressed them a second time.. also, you have no way to know how long each individual control has been held, which is useful in a lot of different situations.
_________________
Chaosmachine Studios: High Quality Homebrew.
Back to top
View user's profile Send private message
LuMo



Joined: 21 Aug 2005
Posts: 410
Location: Austria

PostPosted: Thu Oct 20, 2005 10:38 pm    Post subject: Reply with quote

removed due: posted 2 secs after the post above ;)
_________________
"Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com
Back to top
View user's profile Send private message Visit poster's website
wekilledbambi03



Joined: 15 Oct 2005
Posts: 31

PostPosted: Sat Oct 22, 2005 10:32 am    Post subject: Reply with quote

thanks guys i got the shifting working now. now i gotta jsut work on making a timer and a bunch of other stuff.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.ps2dev.org Forum Index -> PSP Lua Player Development All times are GMT + 10 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group