2

Some of you may have heard of the game called Screen Snake (video here), which allows you to play the game of snake on your screen if you're using a Mac. I had originally thought that the game was taking place on a transparent window, but you can click on any window while the game is running and it will switch to that window. If the window was simply transparent, this would not happen.

How would I go about making something like this? I'm not worried about the snake part (I've made it before), I just don't know how to draw directly on the screen (and not fake directly drawing on the screen through something like a transparent JWindow in Java). Any ideas?

gsgx
  • 12,020
  • 25
  • 98
  • 149
  • Does [this](http://stackoverflow.com/a/2166500/230513) work on Windows? – trashgod Mar 29 '12 at 00:02
  • It probably does (and it's pretty cool), but if you look at the code, their doing what I described: making a transparent frame/window. That would mimic the look of screen snake, but not the functionality of using other programs at the same time. With the window method, the screen would cover any applications you were using so that you couldn't use them even if you could see them. – gsgx Mar 29 '12 at 00:13
  • Just out of interest, have you tried asking the person that made it how they did it? – dann.dev Mar 29 '12 at 00:22
  • @dann.dev Thought never occurred to me... I'll send an email, but it would be nice to have a way to do it in Java, the language I'm most familiar with, and it doesn't seem likely that that software was written in Java, but you never know. – gsgx Mar 29 '12 at 00:44
  • @dann.dev I forgot to post back here, but a while ago I sent them an email and got no response. Still haven't found a solution. – gsgx Apr 30 '12 at 19:52
  • I made something like that, it's actually quite simple. I used C# WPF with a grid and rectangles. https://www.youtube.com/watch?v=BAwBXKicEGs – Marcel Jun 18 '13 at 06:34

2 Answers2

2

I have an idea: pretend that each little square of the snake is a moving window. The "apples" are windows as well. Each time you eat an apple, you grow another window. You just need to figure out how to move the windows efficiently and in a coordinated fashion, but i dont think thats too hard. That way, those windows are always on top of the other windows, not a big window with programs in it, but little windows all over the other ones.

If this helps you make it, please send me a copy of the game! lol.

Damv
  • 36
  • 2
  • This is incredibly clever. I don't know when I'll get around to making this, and I won't be able to test if this method will actually work, but I'm accepting this because it's definitely a plausible approach. – gsgx May 24 '12 at 14:59
1

I was recently at a hackathon (MHacks, if you're curious), and I needed an idea of what to do. I remembered this, and actually made this using JDialogs in Java swing and it was fairly easy. If anyone is trying to do this, remember to call setFocusableWindowState(false) so that the dialogs don't steal focus. The actually hack was that the snake could travel between computer screens, and the full source of the client snake game and the server that synchronizes the clients is available here: https://github.com/gsingh93/snake

Just remember we only had 36 hours to make this so the code is very, very bad. But if anyone is trying to do this it should be fairly straightforward to understand.

gsgx
  • 12,020
  • 25
  • 98
  • 149