Open Surge Forum

A fun 2D retro platformer inspired by Sonic games and a game creation system

You are not logged in.

Announcement

Our community has moved to Discord! https://discord.gg/w8JqM7m

#1 2012-10-10 18:05:06

MatheusRRR
Member
From: Rio de Janeiro, Brazil
Registered: 2012-10-05
Posts: 335
Website

[Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

move "cursor_xpos()" "cursor_ypos()"

This Object-related functions will greatly help in the preparation of a cursor in the game, as an example to select something.

Example

object "Cursor"
{
category "cursor"
    state "main"
    {
    set_animation "SD_CURSOR" 0
    move "cursor_xpos()" "cursor_ypos()"
    }
}

Offline

#2 2012-10-10 19:14:28

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

not really, you can still make your own cursor object and have it read xpos() and ypos(), and save the last known position in $_cursorx and $_cursory, for example.

xpos and ypos are the X and Y positions of the object, $_cursorx and $_cursory would be two global variables where you would save the last xpos() and ypos(), like this:

let "$_cursorx = xpos()"
let "$_cursory = ypos()"

and in this case I chose a global ($_*) instead of a local ($*) because you may want to read the cursor position from any other object, and as long as the cursor has saved its position at least once, any object can get that last position. If it returns 0 on both, it may mean that the cursor never moved, or that it was really at 0, 0 the last time it saved the position. So to test your object i suggest you create it at any other place, like 160, 120, for example. that would be the center of the screen.

Last edited by KZR (2012-10-10 19:17:04)


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#3 2012-10-10 20:23:55

MatheusRRR
Member
From: Rio de Janeiro, Brazil
Registered: 2012-10-05
Posts: 335
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

KZR wrote:

not really, you can still make your own cursor object and have it read xpos() and ypos(), and save the last known position in $_cursorx and $_cursory, for example.

xpos and ypos are the X and Y positions of the object, $_cursorx and $_cursory would be two global variables where you would save the last xpos() and ypos(), like this:

let "$_cursorx = xpos()"
let "$_cursory = ypos()"

and in this case I chose a global ($_*) instead of a local ($*) because you may want to read the cursor position from any other object, and as long as the cursor has saved its position at least once, any object can get that last position. If it returns 0 on both, it may mean that the cursor never moved, or that it was really at 0, 0 the last time it saved the position. So to test your object i suggest you create it at any other place, like 160, 120, for example. that would be the center of the screen.

ok, thanks

Offline

#4 2012-10-11 22:37:50

MatheusRRR
Member
From: Rio de Janeiro, Brazil
Registered: 2012-10-05
Posts: 335
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

It's not working. He is giving bugs to go to the bottom right corner. What do I do?

Offline

#5 2012-10-11 23:36:01

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

can you post your code? smile

Offline

#6 2012-10-12 13:05:31

MatheusRRR
Member
From: Rio de Janeiro, Brazil
Registered: 2012-10-05
Posts: 335
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

Alexandre wrote:

can you post your code? smile

I had put so:

object ".cursor_sprite"
{
always_active
    state "main"
    {
    set_animation SD_ARROW 0
    set_zindex infinity()
    set_absolute_position $_cursorx $_cursory
    }
}
object ".cursor_arrow"
{
always_active
detach_from_camera
    
    state "main"
    {
    hide
    set_animation SD_ARROW 0
    set_absolute_position 160 120
    create_child ".cursor_sprite"

    change_state "input"
    }
    state "input"
    {
    let "$_cursorx = xpos()"
    let "$_cursory = ypos()"
    move "$_cursorx" "$_cursory"
    }
}

Offline

#7 2012-10-12 18:29:35

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

What is it you're intending to do with this cursor, exactly?  Also, why did you separate your animation from your object when it is really a simple matter of getting rid of the hide in the original object and moving your zindex into main of the actual object to have the same effect?


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

#8 2012-10-12 21:12:08

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

MatheusRRR wrote:

It's not working. He is giving bugs to go to the bottom right corner

indeed:

    let "$_cursorx = xpos()"
    let "$_cursory = ypos()"
    move "$_cursorx" "$_cursory"

this won't work as intended.

take a look once again at the move command in the api reference.

Offline

#9 2012-10-13 09:48:18

jobromedia
Member
From: Stockholm, Sweden
Registered: 2009-11-01
Posts: 1,072
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

I can definitely see benefits of having the cursor available for GUI and such things. This will come handy when the options screen gets their final touches.

Offline

#10 2012-10-13 13:09:04

MatheusRRR
Member
From: Rio de Janeiro, Brazil
Registered: 2012-10-05
Posts: 335
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

Alexandre wrote:
MatheusRRR wrote:

It's not working. He is giving bugs to go to the bottom right corner

indeed:

    let "$_cursorx = xpos()"
    let "$_cursory = ypos()"
    move "$_cursorx" "$_cursory"

this won't work as intended.

take a look once again at the move command in the api reference.

alexandre what i can use to get a cursor?

Offline

#11 2012-10-13 13:49:54

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

how do you want to control such a cursor?

keyboard? mouse?

Offline

#12 2012-10-13 19:28:49

MatheusRRR
Member
From: Rio de Janeiro, Brazil
Registered: 2012-10-05
Posts: 335
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

Alexandre wrote:

how do you want to control such a cursor?

keyboard? mouse?

Mouse

Offline

#13 2012-10-13 21:13:57

lunarrush
Member
Registered: 2010-05-13
Posts: 278

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

Just running a quick search against the current API it is currently impossible to read mouse input inside the level.  I know for a fact it can be done in the editor, but in the main level it cannot.  Anyway, perhaps your petition for mouse input should include the following:

  • What is it that having mouse input in levels would accomplish that would make things easier for you, and where in Open Surge would this be used? 

  • Can you name some places where this would greatly enhance the gameplay of both hacks and the main engine game?

  • Can you say how you wish for this to be implemented?  Do you want it to work similar to the way keyboard input currently works, namely that we have a listener that sends out signals when a key is pressed?  Do we need to be able to sense clicks, and would the ability to sense clicks make the object more viable for all involved?

If you include the above your idea to allow for mouse input is more likely to be accepted if the reasoning is good.  Remember, Alexandre has a game he is making and I am currently toying around with Java game design because the Ouya is coming out soon, so it may be a while before your idea sees the light of day.


If I knew then what I know now I'd tell you that the story's true.  Cause whatever you do, it comes back to you.  -Slaughter, Burning Bridges

Offline

#14 2012-10-13 22:21:15

Alexandre
Administrator
From: Brazil
Registered: 2009-01-27
Posts: 3,300
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

it's not possible to read the mouse yet, but the request is already on the todo list. Mouse commands aren't hard to build, but that's not top priority at the moment. sad

today, it's possible to read stuff from the keyboard / joypad. smile

at the moment i'm messing around with the sunshine paradise brickset (trying to make a better brickset, more or less like this one i got online, but using graphics from sunshine paradise). I'm no pixel art guy, but this must be done asap.

Offline

#15 2012-10-14 00:39:05

KZR
Member
Registered: 2010-07-14
Posts: 1,447
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

Alexandre wrote:

at the moment i'm messing around with the sunshine paradise brickset (trying to make a better brickset, more or less like this one i got online, but using graphics from sunshine paradise). I'm no pixel art guy, but this must be done asap.


Can I help?


SD_sml.pngSeD_sml.pngLTot_W_sml.png
https://discord.gg/w8JqM7m ---> Open Surge's Discord server

Offline

#16 2012-10-14 18:30:24

S32X
Member
From: Rochester, New York
Registered: 2012-03-18
Posts: 880
Website

Re: [Suggestion] New Object-related functions cursor_xpos(), cursor_ypos()

Alexandre wrote:

it's not possible to read the mouse yet, but the request is already on the todo list. Mouse commands aren't hard to build, but that's not top priority at the moment.

What about the level editor?

Offline

Board footer

Powered by FluxBB  hosted by tuxfamily.org