| View previous topic :: View next topic |
| Author |
Message |
wekilledbambi03
Joined: 15 Oct 2005 Posts: 31
|
Posted: Wed Oct 19, 2005 11:23 am Post subject: calculating too fast |
|
|
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 |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Wed Oct 19, 2005 1:24 pm Post subject: |
|
|
| 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 |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Wed Oct 19, 2005 6:58 pm Post subject: |
|
|
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 |
|
 |
wekilledbambi03
Joined: 15 Oct 2005 Posts: 31
|
Posted: Thu Oct 20, 2005 11:49 am Post subject: |
|
|
| 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 |
|
 |
wekilledbambi03
Joined: 15 Oct 2005 Posts: 31
|
Posted: Thu Oct 20, 2005 12:44 pm Post subject: |
|
|
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 |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Thu Oct 20, 2005 10:33 pm Post subject: |
|
|
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 |
|
 |
chaos
Joined: 10 Apr 2005 Posts: 135
|
Posted: Thu Oct 20, 2005 10:37 pm Post subject: |
|
|
| 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 |
|
 |
LuMo
Joined: 21 Aug 2005 Posts: 410 Location: Austria
|
Posted: Thu Oct 20, 2005 10:38 pm Post subject: |
|
|
removed due: posted 2 secs after the post above ;) _________________ "Good artists copy, great artists steal."
Pablo Picasso
go2lumo.com |
|
| Back to top |
|
 |
wekilledbambi03
Joined: 15 Oct 2005 Posts: 31
|
Posted: Sat Oct 22, 2005 10:32 am Post subject: |
|
|
| 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 |
|
 |
|