wgois / OIS

Official OIS repository. Object oriented Input System
https://wgois.github.io/OIS/
zlib License
254 stars 86 forks source link

Basic Usage #46

Closed y0dev closed 5 years ago

y0dev commented 5 years ago

Hello I’ve been looking for a c++ library that can be used to detect keystrokes for a space invaders game using no gui I am doing for a class project. The problem I have is my professor wants the project to be compatible to run on Linux and windows. I recently came across your GitHub and seen your repository that looks like it will help, but I don’t understand how to implement it into my project because I don’t see any documentation.

Ybalrid commented 5 years ago

OIS needs to be initialized with a graphical window to be able to capture keyboard/mouse/joystick events. When you say "no GUI" you mean that your program needs to run only on the command-line? If so, I'm affraid OIS isn't going to help...

When you say "no gui" you really mean "no gui" or you just mean not using a widget toolkit (things like Qt, GTK+....)

In any case, we have the documentation fo the OIS API here https://wgois.github.io/OIS/doxygen/html/namespace_o_i_s.html and the repository contains an example program https://github.com/wgois/OIS/blob/master/demos/OISConsoleDemo/OISConsole.cpp

As you will be able to see, even if this program only print infos to the console, it still open a window using the platfrom's specific APIs...

For input/output on the console, on Windows you should have the header shipped with your IDE. But this header is not standard (it's part of old MS-DOS developement tools). It seems that there's an open-souorce implementation of the same API on Linux (built on top of , the Linux equivalent) here https://sourceforge.net/projects/linux-conioh/

If you use this, you will have one single C API to get terminal input that will works on both Windows and Linux.

Also, probably your professor can recommend you what tools you need for your assignment. So check with him/her if you are really stuck.

(just aside : If the program can create a graphical window, I would probably suggest you to try the SDL2library. SDL is a cross-platform "layer" that will permit you to do input and graphics (and other things like loading dynamic libraries, displaying message box dialog, things like that) on pretty much every platform under the sun. It's a valuable tool for any kind of game development if you want to be able to port your program everywhere)

Hope this helps :wink: