Page 1 of 1
Auton vaihde/ohjaus v1
Posted: Sun Dec 21, 2008 12:21 pm
by alker
Tällä koodilla saat vaihdettua auton nopeutta/vaihdetta ja jos vaihde on esim.1 sitten auto ajaa nopeutta jotakin...Olen alottelija ja kertokaa bugit ja korjailla saa koodia
Koodi:
Code: Select all
'Auton ohjaus/vaihteet v1 by Alker'
'Vaihda vaihdetta 1:lle jos painat s:ää,2:lle jos
'painat z,x jos haluat että vaihde on 3:ella
'ja pakki painamalla d nappia
'Kun sinulla on vaihde valittu paina spacea
'niin auto ajaa
Dim vaihde As integer
vaihde = 0
auto = LoadObject("Media\car.bmp")
Repeat
If KeyDown(cbkeys) Then vaihde = 1
If KeyDown(cbkeyd) Then vaihde = 5
If KeyDown(cbkeyz) Then vaihde = 2
If KeyDown(cbkeyx) Then vaihde = 3
If vaihde = 1 Then
If KeyDown(cbkeyspace) Then MoveObject auto,2
EndIf
If vaihde = 2 Then
If KeyDown(cbkeyspace) Then MoveObject auto,4
EndIf
If vaihde = 3 Then
If KeyDown(cbkeyspace) Then MoveObject auto,6
EndIf
If vaihde = 5 Then
If KeyDown(cbkeyspace) Then MoveObject auto,-2
EndIf
DrawScreen
Until EscapeKey()
Re: Auton vaihde/ohjaus v1
Posted: Sun Dec 21, 2008 12:44 pm
by Pettis
Vielä kun teet tuosta yleiskäyttöisen funktion niin heti näyttää paljon paremmalta.
Vanhoilla foorumeilla ainakin joku taisi tutkailla auton vaihteiston mallintamista tarkemminkin, sillä ei auton nopeuden muutokset ihan tuolla tavalla hyppäyksissä tapahdu. Harmi vaan etten muista että kuka...
Re: Auton vaihde/ohjaus v1
Posted: Sun Dec 21, 2008 1:01 pm
by Valtzu
Pettis wrote:Vielä kun teet tuosta yleiskäyttöisen funktion niin heti näyttää paljon paremmalta.
Vanhoilla foorumeilla ainakin joku taisi tutkailla auton vaihteiston mallintamista tarkemminkin, sillä ei auton nopeuden muutokset ihan tuolla tavalla hyppäyksissä tapahdu. Harmi vaan etten muista että kuka...
viewtopic.php?p=878#p878
Tuossapa jonkinlainen..
Re: Auton vaihde/ohjaus v1
Posted: Sun Dec 21, 2008 3:57 pm
by MaGetzUb
Pettis wrote:Vielä kun teet tuosta yleiskäyttöisen funktion niin heti näyttää paljon paremmalta.
Vanhoilla foorumeilla ainakin joku taisi tutkailla auton vaihteiston mallintamista tarkemminkin, sillä ei auton nopeuden muutokset ihan tuolla tavalla hyppäyksissä tapahdu. Harmi vaan etten muista että kuka...
Marcoderhan teki ainakin auton fysiikat, en vain muista linkkiä ulkoa..
Re: Auton vaihde/ohjaus v1
Posted: Sun Dec 21, 2008 4:19 pm
by nevssons
Eikö olisi yksinkertaisempaa hoitaa asia näin?
Code: Select all
'Auton ohjaus/vaihteet v1 by Alker'
'Vaihda vaihdetta 1:lle jos painat s:ää,2:lle jos
'painat z,x jos haluat että vaihde on 3:ella
'ja pakki painamalla d nappia
'Kun sinulla on vaihde valittu paina spacea
'niin auto ajaa
nopeus = 2
auto = LoadObject("Media\car.bmp")
Repeat
If KeyDown(cbkeys) Then nopeus = 2
If KeyDown(cbkeyd) Then nopeus = -2
If KeyDown(cbkeyz) Then nopeus = 4
If KeyDown(cbkeyx) Then nopeus = 6
If KeyDown(cbkeyspace) Then MoveObject auto,nopeus
DrawScreen
Until EscapeKey()
Re: Auton vaihde/ohjaus v1
Posted: Sun Feb 15, 2009 3:13 pm
by elmo123
Joskus koodailin sellaista, että esim. ykkösvaihteella auto kiihtyy nopeasti, mutta huippunopeus ei päätä huimaa. Kakkosvaihde kiihtyy hiukan ykkköstä hitaammin, mutta huippunopeus on hieman isompi jne.
Re: Auton vaihde/ohjaus v1
Posted: Sun Mar 01, 2009 2:19 pm
by cool-driver
Tein tästä tälläisen version.
Code: Select all
Dim vaihde As integer
vaihde = 0
auto = LoadObject("Media\car.bmp")
Repeat
If KeyHit(cbkeya) Then vaihde + 1
If KeyHit(cbkeyz) Then vaihde - 1
If vaihde = -1 Then
If UpKey () Then MoveObject auto, -2
EndIf
If vaihde = 1 Then
If UpKey () Then MoveObject auto,2
EndIf
If vaihde = 2 Then
If UpKey () Then MoveObject auto,4
EndIf
If vaihde = 3 Then
If UpKey () Then MoveObject auto,6
EndIf
If vaihde = 4 Then
If UpKey () Then MoveObject auto,8
EndIf
If vaihde = 5 Then
If UpKey () Then MoveObject auto,10
EndIf
DrawScreen
Eli tähän on lisätty pakki ja vaihteet vaihtuvat a:sta ylöspäin ja z:sta alaspäin.
Re: Auton vaihde/ohjaus v1
Posted: Sun Mar 01, 2009 2:44 pm
by Jani
cool-driver wrote:Tein tästä tälläisen version.
Code: Select all
Dim vaihde As integer
vaihde = 0
auto = LoadObject("Media\car.bmp")
Repeat
If KeyHit(cbkeya) Then vaihde + 1
If KeyHit(cbkeyz) Then vaihde - 1
If vaihde = -1 Then
If UpKey () Then MoveObject auto, -2
EndIf
If vaihde = 1 Then
If UpKey () Then MoveObject auto,2
EndIf
If vaihde = 2 Then
If UpKey () Then MoveObject auto,4
EndIf
If vaihde = 3 Then
If UpKey () Then MoveObject auto,6
EndIf
If vaihde = 4 Then
If UpKey () Then MoveObject auto,8
EndIf
If vaihde = 5 Then
If UpKey () Then MoveObject auto,10
EndIf
DrawScreen
Eli tähän on lisätty pakki ja vaihteet vaihtuvat a:sta ylöspäin ja z:sta alaspäin.
Ehkä tuo eteenpäin meno mieluummin "If UpKey() Then MoveObject auto,vaihde*2"?
Re: Auton vaihde/ohjaus v1
Posted: Sun Mar 01, 2009 4:45 pm
by cool-driver
Jani wrote:cool-driver wrote:Tein tästä tälläisen version.
Code: Select all
Dim vaihde As integer
vaihde = 0
auto = LoadObject("Media\car.bmp")
Repeat
If KeyHit(cbkeya) Then vaihde + 1
If KeyHit(cbkeyz) Then vaihde - 1
If vaihde = -1 Then
If UpKey () Then MoveObject auto, -2
EndIf
If vaihde = 1 Then
If UpKey () Then MoveObject auto,2
EndIf
If vaihde = 2 Then
If UpKey () Then MoveObject auto,4
EndIf
If vaihde = 3 Then
If UpKey () Then MoveObject auto,6
EndIf
If vaihde = 4 Then
If UpKey () Then MoveObject auto,8
EndIf
If vaihde = 5 Then
If UpKey () Then MoveObject auto,10
EndIf
DrawScreen
Eli tähän on lisätty pakki ja vaihteet vaihtuvat a:sta ylöspäin ja z:sta alaspäin.
Ehkä tuo eteenpäin meno mieluummin "If UpKey() Then MoveObject auto,vaihde*2"?
No olen aloittelija joten tuo tuli ensimmäisenä mieleeni.
Edit: Nyt tuli ongelma, se valittaa tuossa kun koitan testata, että "Error in REPEAT Srtucture". Tunti sitten ei tullut nyt tulee, mikä vikana?
Re: Auton vaihde/ohjaus v1
Posted: Sun Mar 01, 2009 10:51 pm
by valscion
cool-driver wrote:Edit: Nyt tuli ongelma, se valittaa tuossa kun koitan testata, että "Error in REPEAT Srtucture". Tunti sitten ei tullut nyt tulee, mikä vikana?
Aloitat loopin REPEAT sanalla mutta et missään vaiheessa sulje sitä "Until <ehto>" tai "Forever" sanoilla.