Skip to content

An addon to iostream that uses windows for some cool classes that help new devs.

Notifications You must be signed in to change notification settings

ScienceKit/ConsolePlusPlus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

ConsolePlusPlus

An addon to iostream that uses windows for some cool classes that help new devs.

For use of the "board", "timer" and "key" classes you give a function pointer as one of the parameters. Expect the function to be called when the key is pressed / x time has passed / char has to be redrawed. Delays are not advised, for the system is single thread. As for the weight of the function you can run some lightweight code in it like updating positions for keys or adding to a variable for timers, but for heavy code just make the program save that it was pressed in a variable and register it when available. You are able to just call the refresh() when available but that can cause some input lag if you have made a 2fps calculation machine.

The "board" class is essentialy an extremely dumbed down version of the windows gdi that calls a proc function for every symbol on the board. The callback blocks the current code execution until the callback returns! The callback function returns a char and has a class coords for a parameter. Make a simple condition that checks the position of an object and if it matches return a char of your coosing, otherwise go to the next if. Acording to this the earleier ifs have higher priority than later ones if the coords overlap. Use the opperators "shiftU", "shiftD", "shiftR", "shiftL" to make objects more than 1 char large. the operator takes a left coords operator and a right int opperator. They return the left shifted by the right. There are also functions for this if opperators are too confusing.

The "coords" class is verry lightweight having only 2 int variables, you can make large arrays of them. their point(pun intended) is to be a member of a game object like say a player or an enemy class. They can be used standalone for some simpler mechanics that do not require more than a position. You can use the '=' opperarator to compare two coords classes. This is verry useful in board proc functions.

The "timer" class relys on the repeated call of the refresh function that executes the callback every x milliseconds. The callback blocks the current code execution until the callback returns! The timer class does not account for lost time due to lag, so for accurate timers use the "Atimer" class.

The "key" class is verry powerful. With it you can read keys with a callback. Again, the whole thing is single thread so you cant place delays and if you dont call the refresh() function as fast as possible the key will have input lag. The callback blocks the current code execution until the callback returns!

The "mouseCoordinates" class is inherited by the board class, dont use it! I still give you the freedom to use it but just use your "board" class as the way you get cursor position. Im asuming the function is going to get called a lot in boardProc so i made a public variable called mousePos of type "coords" that saves the coords of the GetMouseCoordinates() fuction return in it. Call the get mouse coords function in the begining of the proc function!!! also the function is buffered so calling it multiple times asuming the same result will not work. It goes without saying but call it as often as possible. Right now it returns pixels because i cant get the font size function to return an accurate output.

About

An addon to iostream that uses windows for some cool classes that help new devs.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published