Jump to content


Photo
- - - - -

Smart Keys! - V2 Is Here!


  • Please log in to reply
34 replies to this topic

#1 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 12 July 2009 - 07:33 PM

  • Title: Smart Keys
  • Description: Be able to let the player select what keys they want to use!
  • GM Version: GM 7
  • Registered: No, I don't think it requires pro, correct me if I am wrong!!
  • File Type: .gmk
  • File Size: 47 KB
  • File Link(V1): V1: SMART KEYS V1
  • File Link(V2): V2: SMART KEYS V2
  • File Link(V2.5) V2.5 SMART KEYS V2.5


Hello!! Smart Keys is a program I developed to allow people to allow their users to customize their keys. For instance, if you had a controls option screen, you could set the key controls for the player :o. How this works in the file is I have 4 different buttons. Each button corresponds to a value (Up, Down, Left, Right). When you click on the button, then you press a letter or an arrow (That is all I have added for now, more to come in next version :P) and it sets that control to that key. These are stored as global variables which will work throughout the game. Then in the script movement, which I put under the step event, if checks not to see if the left button is pressed. But instead of checking vk_left, it checks global.left. The variable global.left will be set to whatever you choose. The mini game example is in no way a decent game (I just made some crappy sprites by myself and made some quick code ;)). The main purpose of the example is to show you how changing the keys works.

The program is well commented, and is easy to understand.

--------------------------------------------
WORKING CURRENTLY ON Version 3!!!
--------------------------------------------

Features of Version 2:

  • Making the buttons light up DONE!!
  • Making Easy-To-Use Scripts that you can implement in your game without altering code! DONE!!
  • Making custom buttons for game creator defaults (Just like choosing controls in Halo or CoD :() 50% DONE!!!

Features to come in Version 3:

  • Adding all keys on the keyboard DONE!!
  • Now implementing arrays for less code! DONE!!
  • COMMENT AND TELL ME WHAT YOU WANT!! I NEED MORE IDEAS :)

Thank you everyone!! Comment with feedback/glitches of the program so I can fix them!!

Known Glitches/Problems:

  • Text goes outside of box [Fixing :)] FIXED!!

Edited by gblax123, 16 July 2009 - 05:20 AM.

  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#2 mortalpico

mortalpico

    GMC Member

  • New Member
  • 556 posts

Posted 13 July 2009 - 09:33 PM

Great , Useful for games shortcut key!
  • 0
"Remembering ISHIMURA..."

#3 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 13 July 2009 - 10:00 PM

Thanks for the comment :)

More versions on the way!
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#4 mortalpico

mortalpico

    GMC Member

  • New Member
  • 556 posts

Posted 13 July 2009 - 10:01 PM

wow , great PM when the new version was released!

Its very useful for my RTS!
  • 0
"Remembering ISHIMURA..."

#5 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 13 July 2009 - 10:15 PM

Ok yeah, I am going to make easy-to-use functions where you can set, change, and check to see if keys are being pressed!

*UPDATE*

I am completely redoing the system, this time I am implementing more code for easier use :)

Regards, gblax123

Edited by gblax123, 14 July 2009 - 01:45 AM.

  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#6 wa1do_13

wa1do_13

    GMC Member

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

Posted 14 July 2009 - 02:22 AM

Heh, it's funny, I've coincidentally been doing pretty much the same method (global variables) for a very long time, and was considering doing an example soon- but I don't know if it's a good idea to do that anymore. Same concept, but I guess there are a lot of differences in the way we approach it, so maybe I should still do it... eh, whatever...

Anyway, your method has 2 flaws. Firstly, the code is way, way, way too long in the key pressed event, there's a much better way that reduces your code to about 12 lines or so; and secondly, the way that you have it set up to draw is too complicated. Setting up a big slab o' code for each key is a much less efficient way to do this than the other ways. Other than that, nice job, the little example is pretty nice too.
  • 0

I am vengeance, I am the night, I am BATMAN! (Batmans away)

Check out Pandemic here!
Play Pandemic on Facebook here!


#7 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 14 July 2009 - 02:42 AM

Haha, yeah I know! That version literally took me about 20-30 minutes. I am working on so much more to it, including User-Defined events and a lot more user-friendly ways of doing this. Thank you for the feedback =)
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#8 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 14 July 2009 - 03:01 AM

UPDATE:
Finishing up version 2, this includes the ability of using the keys to activate user defined events. I will explain more when I accomplish more :)
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#9 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 14 July 2009 - 03:34 AM

Ok everyone, great news. I have added easy abilities with the User-Defined events. All this requires you to do in the game is add a script to create, and change all of your events to user defined events! Everything else does itself! You will be able to read everything in the "***READ ME***" script, where I explain everything. This Version will be V2, and I have not released it yet. I am going to work out all of the bugs and release it within the next few days. Thanks for all of your support :)

Regards, Gblax123
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#10 Sinister95

Sinister95

    GMC Member

  • New Member
  • 313 posts

Posted 14 July 2009 - 04:05 AM

I reckon you should highlight the selected button so a user would know what he/she is choosing...
  • 0

If I have taken time to help you, you could help me by taking your time to register here: GM Lord or/and ACAnimate It takes a couple of seconds and is painless :)

#11 wa1do_13

wa1do_13

    GMC Member

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

Posted 14 July 2009 - 04:09 AM

That's a cosmetic issue, it doesn't have relevance to the only important aspect of tutorials: the programming. It'd be important in a game, not so much a tutorial.

@gblax123
For future reference, you probably shouldn't make 3 posts in a row like that, moderators will consider that illegal bumping. They say to edit older posts instead. Wouldn't want this to be closed so early on, now, would we?
  • 0

I am vengeance, I am the night, I am BATMAN! (Batmans away)

Check out Pandemic here!
Play Pandemic on Facebook here!


#12 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 14 July 2009 - 04:16 AM

No, your right. My fault. And also, I got the buttons to light up. This will be done by tomorrow (The 15th)
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#13 Sinister95

Sinister95

    GMC Member

  • New Member
  • 313 posts

Posted 14 July 2009 - 04:31 AM

Thats good, and actually I wouldn't think of it as cosmetic, it helps the player see what button he/she will override...
  • 0

If I have taken time to help you, you could help me by taking your time to register here: GM Lord or/and ACAnimate It takes a couple of seconds and is painless :)

#14 mortalpico

mortalpico

    GMC Member

  • New Member
  • 556 posts

Posted 14 July 2009 - 10:57 AM

Yeah , sinister was right!You Need to make it auto light up!
  • 0
"Remembering ISHIMURA..."

#15 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 14 July 2009 - 11:09 AM

Already did :)

Tons of more features also to come!
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#16 mortalpico

mortalpico

    GMC Member

  • New Member
  • 556 posts

Posted 14 July 2009 - 11:44 AM

THNX!
  • 0
"Remembering ISHIMURA..."

#17 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 15 July 2009 - 05:07 AM

Alright everyone, V2 is almost complete. I have run into some serious bugs, and needs users like you to beta test this. If you can identify a problem, and come up with a solution, you will have your name in the credits! I am only allowing 5 people to help me, so PM quick!

Edited by gblax123, 15 July 2009 - 05:10 AM.

  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#18 link2991

link2991

    GMC Member

  • GMC Member
  • 284 posts

Posted 15 July 2009 - 06:17 AM

pro 2nd event in step event

Edited by link2991, 15 July 2009 - 06:18 AM.

  • 0
Posted Image

#19 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 15 July 2009 - 04:49 PM

What?
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#20 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 15 July 2009 - 05:20 PM

Version 2 BETA is out!!!


EDIT:

Due to the fact I have worked out EVERY bug in V2, I need people like you to suggest extra features that I can implement into this program! I am all out of work to do!

Regards, Gblax123

Edited by gblax123, 15 July 2009 - 08:19 PM.

  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#21 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 15 July 2009 - 08:20 PM

Updated a few more features, enjoy :D
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#22 Sinister95

Sinister95

    GMC Member

  • New Member
  • 313 posts

Posted 15 July 2009 - 10:05 PM

Nice orogram, I don't know if it is just my computer but V2 seems to lag just slightly, but thats no problem, good work gblax123!
  • 0

If I have taken time to help you, you could help me by taking your time to register here: GM Lord or/and ACAnimate It takes a couple of seconds and is painless :)

#23 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 16 July 2009 - 03:25 AM

Thanks :D

I am working on getting the code down so it doesn't lag as much... It should be better!

Edited by gblax123, 16 July 2009 - 03:25 AM.

  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#24 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 16 July 2009 - 05:02 AM

No more lag everyone :D

There was a script that repeated every step and it was kinda lengthy. I just narrowed it down so it was only used when it needed to be :D

The link to the new file is at the top! Enjoy!

Regards, Gblax123
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#25 Sinister95

Sinister95

    GMC Member

  • New Member
  • 313 posts

Posted 16 July 2009 - 05:31 AM

Thanks, it's much better now :D
  • 0

If I have taken time to help you, you could help me by taking your time to register here: GM Lord or/and ACAnimate It takes a couple of seconds and is painless :)

#26 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 16 July 2009 - 11:42 AM

I'm glad :D If you have any ideas, I would love to have something to work on :D

Regards, Gblax123
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#27 nicholasandjim

nicholasandjim

    GMC Member

  • New Member
  • 266 posts

Posted 16 July 2009 - 11:07 PM

Great tutorial! I'm not sure what game I could use this in, but it's great! If you need work, you could come and join my Wii PC team! ;)
  • 0


#28 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 17 July 2009 - 03:57 AM

you could use it in ANY game ;) haha!
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#29 frankpiet

frankpiet

    ^destroyed evil chicken^

  • New Member
  • 760 posts

Posted 17 July 2009 - 04:53 AM

Having a look through the scripts (v 2.5) i saw that every time you got a new key you had an if statment to pick the right one. I would reccomend using a switch statment, or making an array at startup with the string stored in the keycode. eg
disp_code[13] would be "RET"(return/enter) and
disp_code[65] would be "A"

then in your script you could just go
my_draw='(disp_code(keyboard_lastkey))'; selected=false;

other than that its good how you use arrays.

Cant think of any other improvments.
  • 0
Posted Image

#30 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 17 July 2009 - 06:01 AM

It is pretty much as good as it can get and I am just letting people use it ;)

Thanks for the comment :P

EDIT:
Alright guys, new goal. I want this to be the Staff Choice! So, I need more from you all! What more could I add??? Just tell me anything that I could improve upon!!

Nominate this is you would like :P This is a universal idea that could be used in EVERY game!

Edited by gblax123, 17 July 2009 - 06:18 AM.

  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#31 frankpiet

frankpiet

    ^destroyed evil chicken^

  • New Member
  • 760 posts

Posted 17 July 2009 - 10:15 AM

Having another look at the way you've done it, you need to be consistient in the way you present it. this means that you need to draw your player in the draw event, rather than transform sprite in the step event. It would be more consistient if you didnt have a single d&d action except execute code. Because you have one script using the function way, you cant use script_execute. More comments, too.

novices will be less confused if you clean up a little bit.

As for more functionallity, how about joysticks? I know its a bit to ask (I tried it with one of my games, by both keypress simulation and if statments but i think i gave up ;) ) but if you could (somehow) incorporate it in the game it would appeal to more.

Some more suggestions but a bit unrealistic is mouse buttons, scroll wheel, and any other input devices.
Good luck getting staff choice!
  • 0
Posted Image

#32 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 17 July 2009 - 12:38 PM

Thank you for the comments, I will try to get in as much as I can ;)

EDIT:
I looked into it. The Joysticks are very complicated and are beyond my capabilities. I myself do not even own a joystick (I actually have this: JOYSTICK, will that work?) But if that does work then I definitely want to try and add it!!!

Edited by gblax123, 17 July 2009 - 01:52 PM.

  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#33 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 20 July 2009 - 01:14 AM

ALRIGHT EVERYONE... AFTER MUCH WORK...

I have begun to get into joysticks. I remembered that I had purchased a nice one a while back, and I started playing around with it. So, now I am working on implementing joysticks into the game! (The hard part is that the joystick can move multiple directions at once, so I will have to find a way for this to work)

Just thought you would like an update as this was dying :GM071:
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#34 gblax123

gblax123

    GMC Member

  • GMC Member
  • 155 posts

Posted 13 September 2009 - 05:28 AM

BUMP, I feel that this deserves a bump, because it is something very useful that I am sure people could implement into their games!
  • 0

Using arrays and other variables, implement Smart Keys into your game to allow players to customize controls! Just change a few scripts and events!

<< Ask me for any scripts I could make for you! PM me!

#35 CaptainLepidus

CaptainLepidus

    GMC Member

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

Posted 13 September 2009 - 03:56 PM

this does require pro, the action 'transform sprite' is only availible in pro.
  • 0

"The reason programming is addictive is the same reason a good game is addictive: it constantly feeds you with a sense of minor accomplishment on your way to [achieving] the greater goal."

Yal

Planning to build a network of like-minded, innovative GameMaker developers, connected by a set of tools for building awesome games. Interested? PM me.