analog stick position

Discuss using and improving Lua and the Lua Player specific to the PSP.

Moderators: Shine, Insert_witty_name

Post Reply
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

analog stick position

Post by wekilledbambi03 »

ive been working on my drag racer game (on pspupdates if anyone wants to try) ive changed it quite a bit so the old versoin is really basic. one thing i wanted to change was the conrols. i want to give the player a better sense of shifting. ive thought about this and thought it would be cool for major games to use. basically you use the analog stick as the shift knob. my problem....ive never been good with the analog stick. could some one give me the position the stick would have to be in for a basic 6 gear setup like this:

1 3 5
|-|-|
2 4 6

basically i need the corners and center top/bottom. thanks
link
Posts: 61
Joined: Wed Oct 19, 2005 6:17 am

Post by link »

I think you might have some very unsatisfied customers if you do that. people trying to go to 1 will go through thrird if not carefull. Its not exact enough to use it as a "free sliding" stick shift. might i suggest using the shoulder buttons so that people wont end up throwing their PSP's against the wall.
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

Post by wekilledbambi03 »

i am currently using the shoulder buttons. i just wanted to see how it would control like that. im sure it would be difficult but i wanted to try something different. i would also put in a clutch so there wont be unwanted shifting. you just have to clutch, push the stick in the right region, and release the clutch and let go of the stick.
the-dan
Posts: 7
Joined: Thu Jul 21, 2005 8:56 am
Contact:

Post by the-dan »

you could just make it a 4speed shifter:


...2
1-|- 4
...3

clutch on Rtrig maybe.. just an idea, but great concept you have goin =)
alexis
Posts: 11
Joined: Mon Nov 14, 2005 10:21 am
Location: between neptune and mars

Post by alexis »

I personnaly feel it could be quite ergonomic with the analog stick to do somethine like

up rigth : up gear spd from odd to even
down rigth : up gear spd from event to odd
up left : down gear spd from odd to even
down left : down gear spd from even to odd

Regards.
Alexis
Ho no ... !! I make the same bug again !!!
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

Post by wekilledbambi03 »

well im glad some people are agreeing with me (kinda) but does anyone know how to do it?
alexis
Posts: 11
Joined: Mon Nov 14, 2005 10:21 am
Location: between neptune and mars

Post by alexis »

K,

Positions of the stick are from -127 to +127.
left X=-127
rigth X=+127
up Y=-127
down Y=+127


I will folow my idea, so the gear system is not like

1 3 5
|-|-|
2 4 6

But more like that

1 3 5
\/\/\
2 4 6
( outch !! ... cops can supress my licence for less than that !!! :D )

In this case I guess somethink like (I din't execute this code!!) ....

Code: Select all


   cnt=Controls.read()

   if cnt&#58;analogX&#40;&#41; > 50 and cnt&#58;analogY&#40;&#41; < -50 then
        -- up rigth position
        if gear==2 or gear==4 then
            gear = gear + 1
        end
    end

   if cnt&#58;analogX&#40;&#41; > 50 and cnt&#58;analogY&#40;&#41; > 50 then
        -- down right position
        if gear==1 or gear==3 or gear==5 then
            gear = gear + 1
        end
    end

   if cnt&#58;analogX&#40;&#41; < -50 and cnt&#58;analogY&#40;&#41; > 50 then
        -- down left position
        if gear==3 or gear==5 then
            gear = gear - 1
        end
    end

   if cnt&#58;analogX&#40;&#41; < -50 and cnt&#58;analogY&#40;&#41; < -50 then
        -- up left position
        if gear==2 or gear==4 or gear==6 then
            gear = gear - 1
        end
    end
.... could give you the sensation to drive a pocket car !! :-D

Additionnaly the folowin little piece code could help you to appreciate a little bit more the analog stick:

Code: Select all

screen&#58;clear&#40;Color.new&#40;0,0,0&#41;&#41;
screen.flip&#40;&#41;
screen.waitVblankStart&#40;&#41;
cnt = Controls.read&#40;&#41;
endloop=false
while not endloop do 
	cn = Controls.read&#40;&#41;
	if cn&#58;analogX&#40;&#41; ~= cnt&#58;analogX&#40;&#41; or cn&#58;analogY&#40;&#41; ~= cnt&#58;analogY&#40;&#41; or cn ~= cnt then
		if cn&#58;select&#40;&#41; then endloop=true end
		screen&#58;clear&#40;Color.new&#40;0,0,0&#41;&#41;
		screen&#58;print&#40;10, 10, "xpos=" .. cn&#58;analogX&#40;&#41; .. " ypos=" .. cn&#58;analogY&#40;&#41;, Color.new&#40;255,255,255&#41;&#41;
		screen.flip&#40;&#41;
		screen.waitVblankStart&#40;&#41;
	end
	cnt = cn

end
Take fun with it.
Alexis
Ho no ... !! I make the same bug again !!!
wekilledbambi03
Posts: 31
Joined: Sat Oct 15, 2005 10:56 am

Post by wekilledbambi03 »

alright thanks for the help. however before i read it i made up my own code. it was really simple once i got the hang of how the stick works. hopefully soon i can implement my sytem into my game. currently i just have it in a seperate file just for testing. i still havent figured out exactly how to work the clutch and such in yet. thatll be tomorrows job. by the way here is the code if anyone was wondering...

Code: Select all

pad = Controls.read&#40;&#41;
	dx = pad&#58;analogX&#40;&#41;
	dy = pad&#58;analogY&#40;&#41;	
if dx > -129 and dx < -100 and dy < -80 then	
	gear = 1
elseif dx > -129 and dx < -100 and dy > 80 then	
	gear = 2
elseif dx > -100 and dx < 100 and dy < -80 then	
	gear = 3
elseif dx > -100 and dx < 100 and dy > 80 then	
	gear = 4
elseif dx > 100 and dx < 129 and dy < -80 then	
	gear = 5
elseif dx > 100 and dx < 129 and dy > 80 then	
	gear = 6
end		
end
alexis
Posts: 11
Joined: Mon Nov 14, 2005 10:21 am
Location: between neptune and mars

Post by alexis »

Great.

I guess now you just have to avoid than the gear go from n to n+k where k>1 or k<-1.

Code: Select all

...
    if posotion == blablablah
        newgear = 3
        if math.abs&#40;gear-newgear&#41;==1 then gear=newgear end
    end
...
Probabely the "blablablah" condition on the position of the stick could be tuned to increase the playability of you drag.

Regards.
Alexis.
Ho no ... !! I make the same bug again !!!
shifty_bill
Posts: 8
Joined: Sat Jan 07, 2006 12:49 pm

Post by shifty_bill »

hey would you be able to update the six way analog example with one that goes 8 ways? thx in advance

Code: Select all

dx = pad&#58;analogX&#40;&#41;
   dy = pad&#58;analogY&#40;&#41;   
if dx > -129 and dx < -100 and dy < -80 then   
   playerstance = greendwarfwalknw
   moving = true
   lastdir = "nw"
   reallastdir = lastdir
   playerx = playerx - 1
   playery = playery - 1
elseif dx > -129 and dx < -100 and dy > 80 then   
   playerstance = greendwarfwalksw
   moving = true
   lastdir = "sw"
   reallastdir = lastdir
   playerx = playerx - 1
   playery = playery + 1
elseif dx > -100 and dx < 100 and dy < -80 then   
   playerstance = greendwarfwalkn
   moving = true
   lastdir = "n"
   reallastdir = lastdir
   playery = playery - 1
elseif dx > -100 and dx < 100 and dy > 80 then   
   playerstance = greendwarfwalks
   moving = true
   lastdir = "s"
   reallastdir = lastdir
   playery = playery + 1
elseif dx > 100 and dx < 129 and dy < -80 then   
   playerstance = greendwarfwalkne
   moving = true
   lastdir = "ne"
   reallastdir = lastdir
   playerx = playerx + 1
   playery = playery - 1
elseif dx > 100 and dx < 129 and dy > 80 then   
   playerstance = greendwarfwalkse
   moving = true
   lastdir = "se"
   reallastdir = lastdir
   playerx = playerx + 1
   playery = playery + 1
elseif dx > 100 and dx < 129 and dy < 80 then   
   playerstance = greendwarfwalke
   moving = true
   lastdir = "e"
   reallastdir = lastdir
   playerx = playerx + 1
elseif dx < -100 and dx > -129 and dy < 80 then   
   playerstance = greendwarfwalkw
   moving = true
   lastdir = "w"
   reallastdir = lastdir
   playerx = playerx - 1
else
moving = false
end 
i figured it out myself :D
Post Reply