Comments (6)
I just started playing with your library, and I noticed that not binding to the root console causes the console to be destroyed. It makes sense, but coming from the C and Python versions it took some time to figure out what was wrong. (I expected to be able to pass () or something similar to the functions that take a console parameter.)
I'm not sure if anything needs to be changed beside adding a warning for new users, I just wanted to give my point of view after using your library for the first time.
from tcod-rs.
Thanks for the feedback!
What exactly do you mean by "not binding to the root console"? Are you calling Console::init_root(...)
, ignoring the return value and then trying to use something like put_char(0, 40, 25, '@', ...)
where 0
is supposed to mean the root console?
Those parts were pretty much the first thing I wrote when I started with Rust so there's a very good chance they're either flat out wrong or not particularly idiomatic.
If you could post a code snippet of what you're trying to achieve and what your failed expectations are, that would be fantastic. I certainly don't want this to be confusing to the existing libtcod users coming from C or Python (other than Rust being a different language).
from tcod-rs.
I don't have the exact code I had written, but I believe I wasn't calling any method that requires a console instance, I was just trying to get the basic event loop working.
I was wondering why the window kept disappearing, until I realized I actually needed the console instance.
from tcod-rs.
Thanks, I see what you mean now.
You're right. This is confusing and it's reasonable to assume that people will start from the bare minimum and work their way up. The root console object shouldn't be necessary unless you're using console-specific commands such as clear
, set_char
, etc.
On the other hand, the non-root consoles have to have a destructor which calls TCOD_console_delete
when they go out of scope (otherwise you get unsafe behaviour).
So how about something like this?
Console::init_root
will return the root console, just like it does today, but you're free to ignore it and nothing will get destroyed.- Because you can ignore the root console but you may end up needing it later, it will also be available as a
tcod::ROOT_CONSOLE
const object. - Non-root consoles will get created by
Console::new(...)
and be dropped when they go out of scope just like today. - TCOD functions that can be used both on root and non-root consoles will be methods of
Console
- TCOD functions that can only be used on the root console will become static methods of
Console
(that's mostly how it is now but some may still be non-static, I'll need to check this)
I do want to add more documentation eventually, but I think this should not present any nasty surprises to existing libtcod users. Do you agree?
from tcod-rs.
@bastienleonard I've pushed something out, it should address the issue you were having.
I've added an examples that seems similar to what you described:
https://github.com/tomassedovic/tcod-rs/blob/master/examples/minimal.rs
Prior to this patch, the window closed immediately but the program kept running (not good), afterwards the window stays up.
Please let me know if this makes sense and if you have any other issues / confusion coming from C/Python.
from tcod-rs.
Thanks for the update Tomas, everything looks good to me.
from tcod-rs.
Related Issues (20)
- Make Map impl Clone HOT 2
- Key::printable ignores modifiers HOT 6
- Cannot build on Antegros Linux HOT 7
- get_default_foreground not wrapped? HOT 2
- Fix deprecation warnings on latest Rust HOT 2
- How to distribute finished game to one directory with CI? HOT 4
- Can't override build script to use existing libtcod HOT 8
- Detect system-installed libtcod through pkg-config
- Running tcod application disabled KDE compositor effects HOT 3
- Switching to fullscreen doesn't work on Ubuntu HOT 10
- WeightedChoice depreciated - Uses old rand::distributions module HOT 2
- Bus error: 10 when adding tcod to a new project on OSX HOT 1
- Segmentation fault on Image creation HOT 3
- Upgrade tcod HOT 1
- Segfault running Dijkstra path finding example HOT 1
- Document dependencies for Fedora
- Cant build project on linux HOT 4
- Panic when using check_for_event HOT 11
- SDL : cannot create window HOT 3
- Build error when adding tcod="0.15" to [dependencies] HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tcod-rs.