Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Cfyz

Pages: 1 ... 9 10 [11] 12 13
151
Programming / Re: Realtime Ruby WASD
« on: August 26, 2014, 10:14:34 AM »
Can't help but recommend to look at my BearLibTerminal library (http://foo.wyrd.name/en:bearlibterminal), it matches pretty much everything you mentioned. Download the archive and skim over the simple demonstrations in SampleOmni app, that should give a good idea of what it capable of.

152
Thanks for your feedback =)

Quote from: Brigand
Do you plan on including any basic drawing functionality? We're just talking simple colored lines, or maybe an ellipse function. (For drawing UI borders and such.)
Not sure. Such "classic" drawing primitives do not combine well with cells/characters architecture. The library does not draw tiles the moment you issue 'put' or 'print' command but constructs a 'scene description' for later render. This allows more 'terminal'-way operation where you can replace some of the characters while leaving everything else intact. This also allows library to redraw the scene all by itself if necessary. Lines and circles are rather foreign to characters-based modifiable scene structure, and I do not see a way to make a clear API with those.

I had considered going all the way to the optional 'custom' output via some callbacks hooked into a scene (e. g. to a layer). Inside callback you would have a different drawing context where you can do things differently because it does not buffer drawing commands. And from the API perspective it becomes very clear that mechanics are different because mode change is intentional and obvious. However, it has a whole new lot of problems not completely thought out yet so the priority of this is fairly low.

As for UI, wouldn't it be enough to just prepare a few tiles for borders and corners?

Quote from: Brigand
When using composition to stack tiles on the same location on the same layer, is there any way to make a copy of the composed tile and save it off as a temporary (or even permanent) tile that can be reused, or would I always need to rebuild (recompose) the tile each move?
Right now the only option is to reconstruct them every time. Given the scene architecture it is not as straightforward as copying pixels, but I think its possible to allow to save an output string (which usually goes to 'print' and supports combining via formatting) as a precomputed template, e. g. like this:
Code: [Select]
terminal_set("0xE100: 'a[+][color=red]/'");
terminal_put(2, 1, 0xE100);
Though it will take a decent amount of coding =).

Quote from: Brigand
Similar to question 2, is there a function to simply copy an area of the screen and paste it somewhere else? (It wouldn't need to retain all the layers; purely just a pixel copy of a designated space, placed into it's own layer in a different spot.)
As I mentioned above, pixel copy is almost impossible and layers do make a problem. However, it indeed may be a useful feature, will think about it. What do you intend to use it for exactly?

153
Programming / Re: Odd behavior of ReadConsoleInput (Windows 7)
« on: August 20, 2014, 03:32:04 PM »
Quote from: Omnivore
Did you use "wine start testprog" or "wineconsole testprog" or something else?
Whoa. As I rarely use Wine, I did not even know about wineconsole. Indeed, after running the snippet application this way, it behaves more like under native Windows and WaitForSingleObject does not hang now. Though output still differs from that under Windows. Wine 1.4 under Ubuntu 12.04:
Keyrelease (I think it is keyrelease) of the modifier key is doubled so Ctrl+A looks like:
Code: [Select]
11-00-08
41-01-08
41-01-08
11-00-00
11-00-00

Depending on the release order (key or modifier released first), this doubled line moves accordingly but somehow mingles with normal ones, e. g. Shift+A:
Code: [Select]
Shift down, A down, A up, Shift up | but Shift down, A down, Shift up, A up
10-00-10                           | 10-00-10
41-41-10                           | 41-41-10
41-41-10                           | 10-41-00
10-00-00                           | 10-00-00
10-00-00                           | 41-00-00
Where I honestly see only chaos.

Alt+A differs only slightly:
Code: [Select]
12-00-02
41-61-02
41-61-02
12-00-00
12-00-00

Quote from: Omnivore
The alternative libraries don't seem to have current D wrappers.
I specifically designed BearLibTerminal's API to simplify wrapping for another languages. If you are interested in this pseudoterminal output approach, I'll make a wrapper for D. Also, BearLibTerminal works fine under Wine (well, at least where I was able to test it).

Quote from: mushroom patch
Get curses <...>
I do not really understand this pure terminal way. It's harder to set up properly. In its extreme it requires networking for no real game purpose. In the end it just shifts the drawing responsibility from external library to external application. And even while using external tools for output it still severely restricts output functionality. Telnet games are cool in their own way but they are harder both ways, requiring more effort from both programmer and player.

154
Programming / Re: Odd behavior of ReadConsoleInput (Windows 7)
« on: August 20, 2014, 10:57:44 AM »
I've tried this snippet under wine 1.6 in ubuntu 14.10. Using MinGW and VC++2012 (no differences between these two). First of all, the program is not working because of WaitForSingleObject call which hangs (waits indefinitely). So there was no output at all and I had to add some before that call to see if program even running. After getting rid of WaitForSingleObject, results are (in VK-Char-State format, hexadecimal):
Code: [Select]
Combination  | Wine      | Windows
-------------+-----------+---------
A            |  41-61-00 | 41-61-00
             |  41-61-00 | 41-61-00
-------------+-----------+---------
Ctrl+A       |  11-00-08 | 11-00-08
             |  00-01-08 | 41-01-08
             |  00-01-08 | 41-01-08
             |  11-00-00 | 11-00-00
-------------+-----------+---------
Shift+A      |  10-00-10 | 10-00-10
             | 141-41-10 | 41-41-10
             | 141-41-10 | 41-41-10
             |  10-00-00 | 10-00-00
-------------+-----------+---------
Ctrl+Shift+A |  11-00-08 | 11-00-08
             |  00-01-08 | 10-00-18
             |  00-01-08 | 41-01-18
             |  11-00-00 | 41-01-18
             |           | 10-00-08
             |           | 11-00-00
-------------+-----------+---------
Alt+A        |  1B-1B-00 | 12-00-02
             |  1B-1B-00 | 41-61-02
             |  41-61-00 | 41-00-02
             |  41-61-00 | 12-00-00
Dunno what all these numbers are good for but once you started collecting data it's hard to stop.

Wine vs Windows aside, I'm curious about two other things.

1. What did you expect from ReadConsoleInput? Console means kind of terminal emulation and obviously some of input will be handled by that terminal program. You do not expect to be able to receive Ctrl+C, do you? Same with Ctrl+D, Ctrl+Z and other special combinations. I believe it is not rational to rely on any Ctrl+<?> key combinations because most users will expect them to be handled predictably by a terminal emulator, not the application running through it. Same with Alt, but this key is usually reserved for a desktop environment (system menus, window modes, etc.). Things are different for windowed applications because they are generally expected to handle input in a more complex way.

2. Why bother with these console input methods? Windows' console support is abysmal even on native platform and I do not believe people motivated to fully implement that in Wine. If you are already ready to go unportable way, why not discard that cmd.exe and use regular windowed API? Despite what written in that WM_KEYDOWN/WM_CHAR article, it is not that bad (or, more like it is equally bad everywhere) and after ruling out some extreme cases it does function consistently. Or event use dedicated output library like libtcod or BearLibTerminal (I couldn't miss this opportunity, could I).

155
Early Dev / Re: The Temple of Torment
« on: August 19, 2014, 09:21:18 AM »
Quote from: Aukustus
However it's a major rewrite to use it instead of libtcod as libtcod handles all the fovs also.
Well, it is only natural for such a rewrite (if any) to be postponed until the right time. However, now the cumulative potential of tools available to you should be somewhat higher =). As for libtcod's fovs, it is BSD licensed and therefore allows extracting parts of the library. It could be something like BearLibTerminal.dll + libtcod-fov.dll.

156
Early Dev / Re: The Temple of Torment
« on: August 18, 2014, 12:21:10 PM »
Aukustus, I'd like you to take a look at my output library attempt: http://foo.wyrd.name/en:bearlibterminal.

From this thread I've noticed you had some troubles with libtcod output (like, 5 months ago? =_=). BearLibTerminal should be able to solve those and a bit more. It supports basic pseudoterminal operations, replacing characters with tiles of arbitrary size (e. g. 8x16 text characters and 16x16 map 'characters'), transparency and stacking, using huge tiles for background, etc. In the latest update I've added a Python wrapper for the library.

157
Another update: v0.11.1: http://foo.wyrd.name/en:bearlibterminal#download

'print' function now allows for text alignment and autowrap. This is done via formatting tags.

Code: [Select]
T.print_(40, 12, "[align=bottom-right]Spike Vixen\nGrease Monk")

Code: [Select]
T.print_(40, 12, "[bbox=30x10]Void Initiate: gain 1 rune. "
                 "You may banish a card in your hand or "
                 "discard pile.")


Dimensions of an autowrapped string may be calculated without printing with the 'measure' function:
Code: [Select]
int height = terminal_measuref(L“[bbox=%d]%ls”, width, ws.c_str());
Using simple in-text iconographics or alternative fonts is a bit easier now:
Code: [Select]
terminal_print(“One [font=0xE000]Two”);

Code: [Select]
T.print_(2, 1, "This spell requires: 2[0xE004] 3[0xE022]")
T.print_(2, 3, "The scroll says \"[font=0xE100]whatewer[/font]\"")


By combining these features it is fairly easy to implement text output with basic formatting, scrolling dynamically adjustable output area. It is demonstrated in SampleOmni showcase. I would add a picture here but it is big and I can't find a spoiler tag =_=.

And there is now a Python wrapper which works with 2.x and 3.x versions:
Code: [Select]
import PyBearLibTerminal as T

T.open()
T.print_(2, 1, “Hello, wordl”)
while True:
    T.refresh()
    key = T.read()
    if key == T.TK_CLOSE or key == T.TK_ESCAPE:
        break
T.close()

#bearlibterminal #nobodycares #everyonereadsthetags

158
Programming / Re: Pixel Dungeon source code
« on: August 07, 2014, 12:40:38 PM »
Quote from: Omnivore
My quoted argument still holds.
Well, if taken literally the statement is undeniably true right now, my bad. However, the initial question was whether is it safe to look at the source code or not.

Quote from: cnet.com
The jury similarly found that Google did not infringe on English-language comments in CodeSourceTest.java and CollectionCertStoreParameters Test.java or source code in seven "Impl.java" files. However, it agreed that Google did infringe on the rangeCheck method in TimSort.java and ComparableTimSort.Java.
Here is the code of rangeCheck:
Code: [Select]
/**
 * Checks that {@code fromIndex} and {@code toIndex} are in
 * the range and throws an appropriate exception, if they aren't.
 */
 private static void rangeCheck(int length, int fromIndex, int toIndex) {
     if (fromIndex > toIndex) {
         throw new IllegalArgumentException(
             "fromIndex(" + fromIndex + ") > toIndex(" + toIndex + ")");
         }
     if (fromIndex < 0) {
         throw new ArrayIndexOutOfBoundsException(fromIndex);
     }
     if (toIndex > length) {
         throw new ArrayIndexOutOfBoundsException(toIndex);
     }
 }
Google might have copied thousands of lines but in the end the war was fought over individual pieces a dozen of lines in length. If you look at some source code you are more likely to write a similar one. With modules as small and trivial as rangeCheck or modules demonstrating some clever trick you might end up writing the same (or very similar) code unintentionally.

My point is, it's just damn scary. I can't guarantee that I would have implemented rangeCheck any differently, both code and comments (having looked at original code at least once and being bound by the similar code conventions).

159
Programming / Re: Pixel Dungeon source code
« on: August 07, 2014, 10:41:04 AM »
Quote from: Omnivore
Nothing in 1452 years of copyright case law leads me to believe that any of the following logically equivalent cases are true <...> A programmer violates copyright if they read any copyrighted source code and then solve the same problem in their own works.
False statement. Oracle vs. Google case has shown one indeed can be attacked because of the code that simply looks copied. This time it ended good. However, it did happen once and monstrous Google being on the receiving end must have contributed greatly to the result.

160
Early Dev / Re: Roguelike distribution question
« on: July 24, 2014, 10:06:35 AM »
Looks like Google products still do not look into .7z archives. This was one of the ways around similar restriction placed on exes in mail attachments and quick test has shown it works for site+chrome as well. 7-zip may be not so widespread as zip or rar but in my opinion it still better than fiddling with file extension.

161
Early Dev / Re: Roguelike distribution question
« on: July 23, 2014, 03:12:27 PM »
Isn't it enough to put the game in archive? It is very common way to distribute programs too.

162
Quote from: Krice
Quote from: Kirbypowered
What would I be missing?
Common sense of not using IDE while it's easier than command line.
When trying out small code snippets It's often easier to type a single command line with few compiler switches than click your mouse to death setting up a new project in an IDE.

163
Quote from: Kirbypowered
What would I be missing?
Code: [Select]
g++ bearlibtest.cpp -o bearlibtest -Iinclude -Llib
You missed to mention the library: -lBearLibTerminal. The -I and -L switches are only telling where to look, not what to look for.

164
Programming / Re: SDL2 getting pixel data from a texture
« on: July 22, 2014, 12:27:27 PM »
Quote from: reaver
I can't find any way to get the pitch which is needed to read the texture pixels.
A brief peek into SDL2 sources revealed that this pitch parameter tells SDL the width of a single line in your buffer, in bytes. SDL copies the data to your buffer line-by-line, incrementing the pointer by that value.

Pages: 1 ... 9 10 [11] 12 13