Jump to content


Photo

[How To] [Studio] A True Analog Stick


  • Please log in to reply
60 replies to this topic

#21 BenRK

BenRK

    Now in high-definition!

  • GMC Member
  • 717 posts
  • Version:GM:Studio

Posted 08 April 2012 - 04:06 AM

I know, and it's becoming a real problem. How can I test these things when they wont even tell me they are there? How they work?

Edited by BenRK, 08 April 2012 - 04:06 AM.

  • 0

#22 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 08 April 2012 - 04:37 AM

That's what the GMC is for. It's a beta. This isn't intended for normal use yet.
  • 0

#23 adam2386

adam2386

    GMC Member

  • New Member
  • 2 posts
  • Version:Unknown

Posted 12 April 2012 - 03:05 PM


Quick question, Lets say I was to make the background bigger so the ship could navigate throughout a map. I have been messing around and when I do that, the analog moves off screen and doesn't stay in the corner to be able to follow the ship.

BTW, way nice example!

Ah, I forgot about that.

Simply add view_xview[0 or 1 or 2..] to everything that has to do with yoyo_mousex and view_yview with everything that has to do with yoyo_mousey. Also add view_xview to everything drawn on the x coordinate and so on and so on.

It'd make it follow the screen. If you don't understand, I could update the example.


Thanks for the quick reply, I should be able to manage without the example, but if it doesn't take too much time to put the example up, that may be good for others who are looking to do the same.
  • 0

#24 time-killer-games

time-killer-games

    GMC Member

  • Banned Users
  • 539 posts
  • Version:GM:Studio

Posted 12 April 2012 - 04:47 PM

H*** yeahh!! I've been waiting forever to find out how to do that ever since ZooEscape by sakis25 games got ported to mobile!
This is awsome! Thanks for such a great example I REALLY apreciate it! :)

#25 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 12 April 2012 - 10:12 PM



Quick question, Lets say I was to make the background bigger so the ship could navigate throughout a map. I have been messing around and when I do that, the analog moves off screen and doesn't stay in the corner to be able to follow the ship.

BTW, way nice example!

Ah, I forgot about that.

Simply add view_xview[0 or 1 or 2..] to everything that has to do with yoyo_mousex and view_yview with everything that has to do with yoyo_mousey. Also add view_xview to everything drawn on the x coordinate and so on and so on.

It'd make it follow the screen. If you don't understand, I could update the example.


Thanks for the quick reply, I should be able to manage without the example, but if it doesn't take too much time to put the example up, that may be good for others who are looking to do the same.

Well in my version of the file, it now supports moving across the room, using the analog stick and virtual button as an overlay. I just need to rip out that code into a new project and post it. I'll do that later tonight, hopefully. (done)

Edited by cotycrg, 28 April 2012 - 12:05 AM.

  • 0

#26 wagdog

wagdog

    GMC Member

  • GMC Member
  • 270 posts
  • Version:GM:Studio

Posted 14 April 2012 - 03:43 AM

Thank you for this example, it was very useful.
  • 0

#27 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 23 April 2012 - 03:00 AM

Finally got around to updating it. Sorry that took so long, I've been working on a million different things. But I put it all aside for this (we need decent analog sticks in people's games!! I hate WASD analogs.. Takes the whole point out of having an analog, and SO many games do that!)
  • 0

#28 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 27 May 2012 - 01:42 PM

Updated to the latest GM:Studio .gmz. Not sure if there is any difference in the file..but either way. Here.
  • 0

#29 Fireball16

Fireball16

    Indie Developer

  • GMC Member
  • 1006 posts
  • Version:GM:Studio

Posted 27 May 2012 - 10:19 PM

Hi quick question before I try this, does it just go I'm the standard 4 ways (up, down, left, right) or 8 ways (north, north east, east, etc)?
  • 0

#30 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 28 May 2012 - 01:55 PM

Hi quick question before I try this, does it just go I'm the standard 4 ways (up, down, left, right) or 8 ways (north, north east, east, etc)?

This does all 360 degrees. It also controls speed. If you make simple if/then checks, then you can make your own 4/8 way things.

eg: if(analog_direction>45 and analog_direction<115){analog_up=1;}else{analog_up=0;}

or something like that. The analog variables that my math returns aren't the standard 0 through 360, simply because of the way cosine/sine work. But just make a little debug text on the top that shows analog_direction and you'll figure it out.
  • 0

#31 Fireball16

Fireball16

    Indie Developer

  • GMC Member
  • 1006 posts
  • Version:GM:Studio

Posted 28 May 2012 - 06:04 PM

Ok, problem. The view is 480px by 320px. When i add the obj_analog to the room, the view for some reason stays really far up in the room (to a bit i havent even made) and all the text i have draw is squished on top of each other... How to fix this?
  • 0

#32 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 29 May 2012 - 04:07 AM

Ok, problem. The view is 480px by 320px. When i add the obj_analog to the room, the view for some reason stays really far up in the room (to a bit i havent even made) and all the text i have draw is squished on top of each other... How to fix this?


That can be one of two things (as I can't access Studio right now, I'm going to try and figure it out in my head. I wish the licensing issue would be fixed already!)

My first idea is that your port is not the same as your view or something. If they are not the same, they need to be at least scaled proportionally correctly.

If they are, then try this code in the create event instead..
Spoiler


Basically this makes the analog a lot smaller and with a smaller boundary.
  • 0

#33 Fireball16

Fireball16

    Indie Developer

  • GMC Member
  • 1006 posts
  • Version:GM:Studio

Posted 29 May 2012 - 06:22 PM


Ok, problem. The view is 480px by 320px. When i add the obj_analog to the room, the view for some reason stays really far up in the room (to a bit i havent even made) and all the text i have draw is squished on top of each other... How to fix this?


That can be one of two things (as I can't access Studio right now, I'm going to try and figure it out in my head. I wish the licensing issue would be fixed already!)

My first idea is that your port is not the same as your view or something. If they are not the same, they need to be at least scaled proportionally correctly.

If they are, then try this code in the create event instead..
Spoiler


Basically this makes the analog a lot smaller and with a smaller boundary.

This works until i click on the analog stick... When i click on it, the same problem occurs.. the view goes odd.
  • 0

#34 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 29 May 2012 - 09:59 PM

This works until i click on the analog stick... When i click on it, the same problem occurs.. the view goes odd.

..you must be doing something seriously wrong in your code, haha. If you want, you can PM me an example of what you're trying to do and I can try debugging it for you.
  • 0

#35 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 07 June 2012 - 12:03 AM

!

Turns out there was a little bug in my example. When you would try to move your ship to far right (when using a move-able view), you would end up pressing right on the analog stick if you hit "shoot" on a mobile device. I fixed it in the OP, though.

Specifically, it's this line..
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5))+view_yview or device_used=ddevice)){

Change it to this...
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5)+view_yview) or device_used=ddevice)){

  • 0

#36 ObsidianNovels

ObsidianNovels

    GMC Member

  • GMC Member
  • 353 posts
  • Version:GM:HTML5

Posted 22 June 2012 - 09:09 AM


Hi quick question before I try this, does it just go I'm the standard 4 ways (up, down, left, right) or 8 ways (north, north east, east, etc)?

This does all 360 degrees. It also controls speed. If you make simple if/then checks, then you can make your own 4/8 way things.

eg: if(analog_direction>45 and analog_direction<115){analog_up=1;}else{analog_up=0;}

or something like that. The analog variables that my math returns aren't the standard 0 through 360, simply because of the way cosine/sine work. But just make a little debug text on the top that shows analog_direction and you'll figure it out.


Simply add this little code into the step-event and refer to it to get the normal 0-360 degrees:

currentAngle = analog_direction_ship mod 360;
if (analog_direction_ship < 0) currentAngle += 360;

Love your example, cotycrg. It's very good!
  • 0

#37 japes00

japes00

    GMC Member

  • GMC Member
  • 48 posts
  • Version:GM:Studio

Posted 10 July 2012 - 11:52 AM

!

Turns out there was a little bug in my example. When you would try to move your ship to far right (when using a move-able view), you would end up pressing right on the analog stick if you hit "shoot" on a mobile device. I fixed it in the OP, though.

Specifically, it's this line..

 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5))+view_yview or device_used=ddevice)){

Change it to this...
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5)+view_yview) or device_used=ddevice)){


Great example... but this bug also happens if you place the stick on the right hand side,
also if you press on the top of a screen ( same side as the stick) it also happens.
  • 0

#38 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 12 July 2012 - 04:01 AM


!

Turns out there was a little bug in my example. When you would try to move your ship to far right (when using a move-able view), you would end up pressing right on the analog stick if you hit "shoot" on a mobile device. I fixed it in the OP, though.

Specifically, it's this line..

 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5))+view_yview or device_used=ddevice)){

Change it to this...
 if (YoYo_MouseCheckButton(ddevice,mb_left) and ((YoYo_MouseX(ddevice)>((analog_x)/4)+view_xview and YoYo_MouseY(ddevice)>((analog_y)/4)+view_yview and  YoYo_MouseX(ddevice)<((analog_x+analog_width)*1.5)+view_xview and YoYo_MouseY(ddevice)<((analog_y+analog_height)*1.5)+view_yview) or device_used=ddevice)){


Great example... but this bug also happens if you place the stick on the right hand side,
also if you press on the top of a screen ( same side as the stick) it also happens.


It's not a bug, it's deadzone configuration. Just replace what you quoted and it "fixes" it. Compare the two to see how I did the deadzone. I'll update the example soon to have a "deadzone" variable so its easier to mess with.
  • 0

#39 Mariux

Mariux

    GMC Member

  • GMC Member
  • 1 posts
  • Version:GM:Studio

Posted 30 July 2012 - 01:09 PM

Hi,

first of all thanks for this great example!

Let's say I want to add to my object a constant speed of +2 in x axis in order to follow a the view (that's moving to the right with a speed of -2), where I have to edit the x movement?

Thanks!

Edited by Mariux, 30 July 2012 - 01:11 PM.

  • 0

#40 cotycrg

cotycrg

    GMC Member

  • GMC Member
  • 851 posts
  • Version:GM:Studio

Posted 03 August 2012 - 12:59 AM

..do you mean similar to how Scribble Space works? (Basically you're always going right).

In which case; it might be easier to make everything else go left. Or, just do something different than I'm doing with speeds. Just do hspeed=2 or something?
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users