Topic:   Sc B3 in time for the Gmg Cup?   (Read 13184 times)


0 Members and 1 Guest are viewing this topic.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Sc B3 in time for the Gmg Cup?
« on: December 07, 2010, 06:56:10 PM »
I'm working on my engine for the contest and it'd be great if Sc B3 could be released before Dec 20th.
Sprite rotation and the KeyUp method are what I'm really needing.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Sc B3 in time for the Gmg Cup?
« Reply #1 on: December 07, 2010, 07:36:05 PM »
I was saying the same thing!
I'd use Key Up so much... Or at least those arrow key commands.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Sc B3 in time for the Gmg Cup?
« Reply #2 on: December 08, 2010, 10:18:01 PM »
It looks like REALbasic has a Key Up event.

All of this keyboard support really sucks though. Key Down is already pretty lousy and shouldn't be used for games at all. It should only be used for creating fake text fields like in the Palace Chat demo. Consider the fact that someone could simply adjust their key repeat rate to be very high and they would have an advantage in any game that uses Key Down to fire a weapon.

Another problem with Key Down is: what if they have a Dvorak keyboard?

OK, you say, who the hell uses Dvorak anyway? Consider instead a regular style French keyboard, pictured below:



What if you set up your game to use WASD for the movement? The French user would be completely screwed.

The solution to this problem, as implemented in REALbasic, is Key Codes - but I've resisted putting in key codes because the idea can be confusing to new programmers.

The idea of key codes is that instead of checking if the user is pressing "A", you instead check to see if the user is pressing the button where "A" typically is on a standard US English keyboard.

Map of keycodes: http://boredzo.org/blog/wp-content/uploads/2007/05/imtx-virtual-keycodes.png

The key codes are the same on Mac or Windows, I believe.

That way, instead of hard coding in your game "WASD", you would do something like this:

Code: [Select]
PRINT "To move left, press " + KEYNAME$(0)
PRINT "To move right, press " + KEYNAME$(2)
PRINT "To move up, press " + KEYNAME$(13)
PRINT "To move down, press " + KEYNAME$(1)

Then you would do something like this to check for movement in your TIMER:

Code: [Select]
IF KEYCODE(0) = TRUE THEN
   // they are pressing left
END IF
IF KEYCODE(2) = TRUE THEN
   // they are pressing right
END IF
IF KEYCODE(13) = TRUE THEN
   // they are pressing up
END IF
IF KEYCODE(1) = TRUE THEN
   // they are pressing down
END IF

Now this allows you to hold down multiple keys at the same time! What if they press left AND right at the same time? More code (this also applies to the regular arrow checking variables as well):

Code: [Select]
LET LEFT = FALSE
LET RIGHT = FALSE
LET UP = FALSE
LET DOWN = FALSE
LET KEYS = 0
IF KEYCODE(0) = TRUE THEN
   LET LEFT = TRUE
   LET KEYS += 1
END IF
IF KEYCODE(2) = TRUE THEN
   LET RIGHT = TRUE
   LET KEYS += 1
END IF
IF KEYCODE(13) = TRUE THEN
   LET UP = TRUE
   LET KEYS += 1
END IF
IF KEYCODE(1) = TRUE THEN
   LET DOWN = TRUE
   LET KEYS += 1
END IF
IF KEYS > 1 THEN
   NOTEALERT "What the hell"
ELSE
   // blah
END IF

It all gets very messy. I don't know of an elegant way to handle it.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Sc B3 in time for the Gmg Cup?
« Reply #3 on: December 08, 2010, 10:24:00 PM »
Truthfully just make a KeyUp and KeyDown. Forget keycodes. If someone wants to support the french keyboard then they can code in the support themselves.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Sc B3 in time for the Gmg Cup?
« Reply #4 on: December 08, 2010, 11:00:59 PM »
Can't use REALBasic, just the standard GM/SC for this one. :-/
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Sc B3 in time for the Gmg Cup?
« Reply #5 on: December 08, 2010, 11:16:19 PM »
Quote
Can't use REALBasic, just the standard GM/SC for this one. :-/


SilverCreator is made in REALbasic though.

Xiphos


  • GMG-er

  • **


  • Posts: 676
Re: Sc B3 in time for the Gmg Cup?
« Reply #6 on: December 11, 2010, 11:04:36 AM »
In the timer would a code like this work?

TIMER x
IF key$=right$ THEN
END IF
END TIMER

If yes then we can just allow users to choose there own keys, but only let them be characters, and not numbers/ keydown.

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Sc B3 in time for the Gmg Cup?
« Reply #7 on: December 11, 2010, 12:18:58 PM »
That code would work.

It'd be easy to let the player choose their own keys. What we really need is a KeyUp method now that this is sorted out.

EqwanoX


  • Administrator

  • GMG Extraordinaire

  • *****


  • Posts: 1180
Re: Sc B3 in time for the Gmg Cup?
« Reply #8 on: December 11, 2010, 12:37:49 PM »
im looking foward to this new key support stuff, it'll make controls much tighter and responsive

couldnt you do diagonal movement like this in a timer

if up=true then pushsprite 1, 0,-10, 1
if right=true then pushsprite 1, 10,0, 1

updatescreen

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Sc B3 in time for the Gmg Cup?
« Reply #9 on: January 01, 2011, 04:19:18 PM »
How's it going Mike?

Everyone's incredibly excited for the new Sc release.

GMG Mike


  • Administrator

  • GMG-er

  • *****

  • no avatar

  • Posts: 536
    • mikerichardson.name
Re: Sc B3 in time for the Gmg Cup?
« Reply #10 on: January 04, 2011, 12:16:50 AM »
Unfortunately I've had to put the release on hold to take care of some other stuff in life. I can't guarantee it for the contest but it will be released soon.

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Sc B3 in time for the Gmg Cup?
« Reply #11 on: January 04, 2011, 12:34:41 PM »
Good thing I'm not making an arcader anymore...
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Sc B3 in time for the Gmg Cup?
« Reply #12 on: January 04, 2011, 02:54:15 PM »
Well, looks like I'll probably submit my game for the next contest.  :-/

Connors


  • ^ This guy is amazing.

  • ****


  • Posts: 2374

  • It's a secret to everyone...
Re: Sc B3 in time for the Gmg Cup?
« Reply #13 on: January 04, 2011, 05:45:46 PM »
Have you tried controlling with the mouse?
Oh wait I don't even know what you were planning to make.
Warning: The above post may have been modified multiple times.

"In a great game, the character must never perfectly obey the user's command"
 - Tim Rogers

http://connorspuzzles.tumblr.com/

Gan


  • Administrator

  • ^ This guy is amazing.

  • *****


  • Posts: 4411
Re: Sc B3 in time for the Gmg Cup?
« Reply #14 on: January 04, 2011, 06:31:23 PM »
A defense game where the main player is a sphere tank with a turrent. The mouse would be used to shoot bullets while the aswd keys rolled the tank around. I need sprite rotation and smooth key methods to make it though. :/