Install Steam
login
|
language
简体中文 (Simplified Chinese)
繁體中文 (Traditional Chinese)
日本語 (Japanese)
한국어 (Korean)
ไทย (Thai)
Български (Bulgarian)
Čeština (Czech)
Dansk (Danish)
Deutsch (German)
Español - España (Spanish - Spain)
Español - Latinoamérica (Spanish - Latin America)
Ελληνικά (Greek)
Français (French)
Italiano (Italian)
Bahasa Indonesia (Indonesian)
Magyar (Hungarian)
Nederlands (Dutch)
Norsk (Norwegian)
Polski (Polish)
Português (Portuguese - Portugal)
Português - Brasil (Portuguese - Brazil)
Română (Romanian)
Русский (Russian)
Suomi (Finnish)
Svenska (Swedish)
Türkçe (Turkish)
Tiếng Việt (Vietnamese)
Українська (Ukrainian)
Report a translation problem
prevMouseX = mouse_x;
xMove = 0;
In step event:
if mouse_x > prevMouseX
{
xMove += 1;
}
else if mouse_x < prevMouseX
{
xMove -= 1;
}
x += xMove;
In end step event:
prevMouseX = mouse_x;
It'll be really hard to stop moving with this control scheme, I think that might be intentional for your controls? If not, you might want a manual way for the player to stop moving
In keystroke/mousePressed/whatever trigger you desire event:
xMove = 0;
prevMouseX = mouse_x;
Hope that helps.
I know mouse camera controls typically reset the mouse position every frame, which would let you omit the prevMouse variables if you can do similar (I forget is mouse_x is read only, but I think there's a function somewhere, worst case) and also would stop the edge of the screen being hit, a situation which would result in the player suddenly being unable to move because the mouse can't move any further in a given direction, rendering nobody very happy.
For 4 directions, you'll need to alter the step event to compare the difference between mouse_x and prevMouseX and the difference between mouse_y and prevMouseY, then move horizontally or vertically based on which is greater:
if abs(mouse_x - prevMouseX) > abs(mouse_y -prevMouseY)
{
if mouse_x > prevMouseX
{
xMove = 1;
}
else if mouse_x < prevMouseX
{
xMove = -1;
}
x += xMove;
}
else if abs(mouse_x - prevMouseX) < abs(mouse_y -prevMouseY)
{
[same stuff, but for y]
}
As long as your player makes an effort not to move the mouse at 45 degree angles, one and only one of the conditions will evaluate, giving you 4 distinct directions to move in.
-no visible mouse cursor
-don't trail the mouse (because there's no visible cursor)
-no clicking of the mouse necessary
-object shouldn't simply "become" the mouse cursor
I'm having a hard time picturing a control scheme that meets all of those criteria. What about this: Use left/right movement of the mouse to rotate the sword like a clock hand to point toward your intended target. When you have the attack lined up the way you want, swipe the mouse upward to launch it. To return your sword to ready position, swipe the mouse downward. Would that work? It would be similar to the four direction control scheme, but instead of moving the object to the left and right in the x-movement checks, it would rotate the image of your weapon clockwise or counter clockwise. In the y-movement checks, swiping upward would move the sword in the direction its been pointed in at whatever speed you desire. The downward swipe would move it back to ready position (will need variables to assign this at creation) and reset the angle of its rotation.
I feel like this probably isn't exactly what you're looking for, but I can't picture anything else right now that meets the requirements. Fun problem to think about though!