5 Replies - 762 Views - Last Post: 02 December 2011 - 12:55 AM Rate Topic: -----

#1 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

SDL right click option

Posted 29 November 2011 - 05:32 PM

Hello, guys I am currently working on a project for a marine ecosystem simulation.

I am using SDL for GUI and i had a nice idea but i dont know how easy is it to be done.

Basically, i want to somehow give the user a feature in which he will be able to right click on a spot into the screen and if its
1)NULL which means sea ==> he could add a new fish etc
2)Fish item ==> he could delete it etc etc

And all these could happen by right clicking the right spot. I know how to understand in which sprite the user will click, but i have no idea how to show up a right click options menu.( Like in OSes etc )

Thanks in advance :)

Is This A Good Question/Topic? 0
  • +

Replies To: SDL right click option

#2 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

Re: SDL right click option

Posted 30 November 2011 - 05:47 AM

Well i discovered that its kinda hard to code something like this..

So i am thinking of making the user interface a combination of SDL GUI and command prompt.

Is it possible to run SDL GUI window pararell with a cmd prompt in order that the user will be able to select options from a menu and see the result on the GUI screen ??
Was This Post Helpful? 0
  • +
  • -

#3 stayscrisp  Icon User is offline

  • フカユ
  • member icon

Reputation: 1011
  • View blog
  • Posts: 4,215
  • Joined: 14-February 08

Re: SDL right click option

Posted 30 November 2011 - 06:15 AM

I don't think it would be particularly hard to code something like this. Just create some GUI objects and then add them to the location of the mouse click, check them for mouse click events and then remove them when done. Doing it from the command prompt would be kinda annoying.

Or check out some libraries, like this: http://www.alhem.net/project/gui/
Was This Post Helpful? 0
  • +
  • -

#4 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

Re: SDL right click option

Posted 30 November 2011 - 12:25 PM

View Poststayscrisp, on 30 November 2011 - 06:15 AM, said:

I don't think it would be ......
Or check out some libraries, like this: http://www.alhem.net/project/gui/


Ok thanks a bunch. You are helping me a lot.

If i can imagine the game i would say that i want it like this :

It begins at PlayGame State( like you did on your tutorials ) and when the user presses a button ( like SPACE )
then the game is paused to THE LAST screen it was showing up( a specific day-moment on the simulation ).

So when the game is paused the user will have the option to press on a fish and ( while catching the mouse down event ) and manage that item. Like delete it or view some information about it.
Similarly when the user clicks on a NULL cell ( the sea ) he will have another menu to add a new fish etc.

[ Actually my problem over here is how to pause the game and keep getting mouse events. More clearly i want my game screen to be paused and the user to be able to click on a fish, and hopefully ill get the event->motion.x and y ]

So basically i need to have 1 PlayState and somehow pause that one ( maybe a PauseState remembering the last situation of the simulation ) and a MenuState, which will come up when user pauses the game and then selects an object.

I hope i didnt confuse you..

Any help or option is totally accepted. Thanks in advance :)
P.S. Sorry for my terrible english.
Was This Post Helpful? 0
  • +
  • -

#5 anonymous26  Icon User is offline

  • D.I.C Lover

Reputation: 1
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: SDL right click option

Posted 01 December 2011 - 03:25 PM

View Posts0me0ne, on 30 November 2011 - 12:32 AM, said:

Basically, i want to somehow give the user a feature in which he will be able to right click on a spot into the screen and if its
1)NULL which means sea ==> he could add a new fish etc

No, this is very bad programming practice! NULL is reserved for the absence of data and should not be used to indicated anything else. Find a way to represent 'sea' like an enumeration of something.

View Posts0me0ne, on 30 November 2011 - 12:32 AM, said:

2)Fish item ==> he could delete it etc etc

And all these could happen by right clicking the right spot. I know how to understand in which sprite the user will click, but i have no idea how to show up a right click options menu.( Like in OSes etc )

Thanks in advance :)

So you need to work out how to track your resources, as well as dynamically create and delete them. Look into lists and structures for quick solutions.
Was This Post Helpful? 0
  • +
  • -

#6 s0me0ne  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 35
  • Joined: 05-November 11

Re: SDL right click option

Posted 02 December 2011 - 12:55 AM

Thanks for replying :)

Yeah i will change sea's id to -1 :)

I think i figured out how to make it work. I had the problem that i needed the user to PAUSE the game, but i should be able still to catch events. I fixed that using an manual pause into events which stops running the rest program + Rendering so practically i' ve got pause.
( I am just mentioning it in case someone will try using kbhit, wait or sleep functions, which will not work because they suspend the execution of the game )

So, thanks a bunch everyone :). Im gonna add dreamincode.net at the credits hehe :P
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1