analog stick position
Moderators: Shine, Insert_witty_name
- 
				wekilledbambi03
 - Posts: 31
 - Joined: Sat Oct 15, 2005 10:56 am
 
analog stick position
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
			
			
									
									
						1 3 5
|-|-|
2 4 6
basically i need the corners and center top/bottom. thanks
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
 
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.
			
			
									
									
						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
			
			
									
									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
 
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!!) ....
 .... 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:
Take fun with it.
Alexis
			
			
									
									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:analogX() > 50 and cnt:analogY() < -50 then
        -- up rigth position
        if gear==2 or gear==4 then
            gear = gear + 1
        end
    end
   if cnt:analogX() > 50 and cnt:analogY() > 50 then
        -- down right position
        if gear==1 or gear==3 or gear==5 then
            gear = gear + 1
        end
    end
   if cnt:analogX() < -50 and cnt:analogY() > 50 then
        -- down left position
        if gear==3 or gear==5 then
            gear = gear - 1
        end
    end
   if cnt:analogX() < -50 and cnt:analogY() < -50 then
        -- up left position
        if gear==2 or gear==4 or gear==6 then
            gear = gear - 1
        end
    end
Additionnaly the folowin little piece code could help you to appreciate a little bit more the analog stick:
Code: Select all
screen:clear(Color.new(0,0,0))
screen.flip()
screen.waitVblankStart()
cnt = Controls.read()
endloop=false
while not endloop do 
	cn = Controls.read()
	if cn:analogX() ~= cnt:analogX() or cn:analogY() ~= cnt:analogY() or cn ~= cnt then
		if cn:select() then endloop=true end
		screen:clear(Color.new(0,0,0))
		screen:print(10, 10, "xpos=" .. cn:analogX() .. " ypos=" .. cn:analogY(), Color.new(255,255,255))
		screen.flip()
		screen.waitVblankStart()
	end
	cnt = cn
end
Alexis
Ho no ... !!  I make the same bug again !!!
						- 
				wekilledbambi03
 - Posts: 31
 - Joined: Sat Oct 15, 2005 10:56 am
 
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()
	dx = pad:analogX()
	dy = pad:analogY()	
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		
endGreat.
I guess now you just have to avoid than the gear go from n to n+k where k>1 or k<-1.
Probabely the "blablablah" condition on the position of the stick could be tuned to increase the playability of you drag.
Regards.
Alexis.
			
			
									
									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(gear-newgear)==1 then gear=newgear end
    end
...
Regards.
Alexis.
Ho no ... !!  I make the same bug again !!!
						- 
				shifty_bill
 - Posts: 8
 - Joined: Sat Jan 07, 2006 12:49 pm
 
hey would you be able to update the six way analog example with one that goes 8 ways? thx in advance
i figured it out myself :D
			
			
									
									
						Code: Select all
dx = pad:analogX()
   dy = pad:analogY()   
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