aboutsummaryrefslogtreecommitdiff
path: root/cube.c (follow)
Commit message (Collapse)AuthorAge
...
* Better mouse button handling in Mines:Simon Tatham2005-05-31
| | | | | | | | | | | | | - middle button now also triggers the clear-around-square action - a special-case handler in midend_process_key() arranges that the left button always trumps the right button if both are pressed together, meaning that Windows Minesweeper players used to pressing L+R to clear around a square should still be able to do so without any strange behaviour. (The latter touches all game backends, yet again, to add a field to the game structure which is zero in everything except Mines.) [originally from svn r5888]
* Move definition of PI into puzzles.h. If nothing else, the definition in cube.cJacob Nevins2005-05-31
| | | | | | had a typo :) [originally from svn r5878]
* Mouse-based interface for Cube: you left-click anywhere on the gridSimon Tatham2005-05-31
| | | | | | | | | | | | | | | and it moves the polyhedron in the general direction of the mouse pointer. (I had this in my initial throwaway Python implementation of this game, but never reimplemented it in this version. It's harder with triangles, but not too much harder.) Since the logical-to-physical coordinate mapping in Cube is dynamically computed, this has involved an interface change which touches all puzzles: make_move() is now passed a pointer to the game_drawstate, which it may of course completely ignore if it wishes. [originally from svn r5877]
* Added an `interactive' flag to new_game_desc(), which toggles MinesSimon Tatham2005-05-30
| | | | | | | | | between on the one hand generating indeterminate game descriptions awaiting the initial click, and on the other hand generating concrete ones which have had their initial click. This makes `mines --generate' do something useful. [originally from svn r5869]
* First cut at a game timer. Yet another backend function whichSimon Tatham2005-05-30
| | | | | | | | | | | | | | | indicates whether a particular game state should have the timer going (for Mines the initial indeterminate state does not have this property, and neither does a dead or won state); a midend function that optionally (on request from the game) prepends a timer to the front of the status bar text; some complicated midend timing code. It's not great. It's ugly; it's probably slightly inaccurate; it's got no provision for anyone but the game author decreeing whether a game is timed or not. But Mines can't be taken seriously without a timer, so it's a start. [originally from svn r5866]
* Mines now follows the conventional approach of offering a completelySimon Tatham2005-05-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | blank grid until you make the first click; to ensure solubility, it does not generate the mine layout until that click, and then ensures it is solvable starting from that position. This has involved three infrastructure changes: - random.c now offers functions to encode and decode an entire random_state as a string - each puzzle's new_game() is now passed a pointer to the midend itself, which most of them ignore - there's a function in the midend which a game can call back to _rewrite_ its current game description. So Mines now has two entirely separate forms of game ID. One contains the generation-time parameters (n and unique) plus an encoding of a random_state; the other actually encodes the grid once it's been generated, and also contains the initial click position. When called with the latter, new_game() does plausibly normal stuff. When called with the former, it notes down all the details and waits until the first square is opened, and _then_ does the grid generation and updates the game description in the midend. So if, _after_ your first click, you decide you want to share this particular puzzle with someone else, you can do that fine. Also in this checkin, the mine layout is no longer _copied_ between all the game_states on the undo chain. Instead, it's in a separate structure and all game_states share a pointer to it - and the structure is reference-counted to ensure deallocation. [originally from svn r5862]
* Infrastructure change: game_anim_length and game_flash_length nowSimon Tatham2005-05-30
| | | | | | | | | both get passed a pointer to the game_ui. This means that if they need to note down information for the redraw function about what _type_ of flash or animation is required, they now have somewhere to do so. [originally from svn r5858]
* Add origin-shifting (Shift+cursors) and source-shifting (Ctrl+cursors) to Net.Jacob Nevins2005-05-26
| | | | | | | | | | | | (Adding modifier+cursors handling has had minor knock-on effects on the other puzzles, so that they can continue to ignore modifiers.) (An unfortunate side effect of this is some artifacts in exterior barrier drawing; notably, a disconnected corner can now appear at the corner of the grid under some circumstances. I haven't found a satisfactory way round this yet.) [originally from svn r5844]
* Cube's dup_game() function was missing a field. Oops.Simon Tatham2005-05-17
| | | | [originally from svn r5789]
* The game IDs for Net (and Netslide) have always been random seedsSimon Tatham2005-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rather than literal grid descriptions, which has always faintly annoyed me because it makes it impossible to type in a grid from another source. However, Gareth pointed out that short random-seed game descriptions are useful, because you can read one out to someone else without having to master the technology of cross- machine cut and paste, or you can have two people enter the same random seed simultaneously in order to race against each other to complete the same puzzle. So both types of game ID seem to have their uses. Therefore, here's a reorganisation of the whole game ID concept. There are now two types of game ID: one has a parameter string then a hash then a piece of arbitrary random seed text, and the other has a parameter string then a colon then a literal game description. For most games, the latter is identical to the game IDs that were previously valid; for Net and Netslide, old game IDs must be translated into new ones by turning the colon into a hash, and there's a new descriptive game ID format. Random seed IDs are not guaranteed to be portable between software versions (this is a major reason why I added version reporting yesterday). Descriptive game IDs have a longer lifespan. As an added bonus, I've removed the sections of documentation dealing with game parameter encodings not shown in the game ID (Rectangles expansion factor, Solo symmetry and difficulty settings etc), because _all_ parameters must be specified in a random seed ID and therefore users can easily find out the appropriate parameter string for any settings they have configured. [originally from svn r5788]
* I've had two complaints that Solo ought to recognise the numericSimon Tatham2005-05-12
| | | | | | | | | | | | | | | | keypad. The reason it doesn't is because front ends were carefully translating the numeric keypad into 8-way directional keys for the benefit of Cube. Therefore, a policy change: - front ends process the numeric keypad by sending MOD_NUM_KEYPAD | '3' and similar - front ends running on a platform with Num Lock SHOULD do this _irrespective_ of the state of Num Lock - back ends do whatever they see fit with numeric keypad keys. Result: the numeric keypad now works in Solo, and also works in OS X Cube (which it previously didn't because I forgot to implement that bit of the front end!). [originally from svn r5774]
* Silly (but harmless) typo.Simon Tatham2005-05-02
| | | | [originally from svn r5732]
* Added an automatic `Solve' feature to most games. This is useful forSimon Tatham2005-05-02
| | | | | | | | | | | | | | | | various things: - if you haven't fully understood what a game is about, it gives you an immediate example of a puzzle plus its solution so you can understand it - in some games it's useful to compare your solution with the real one and see where you made a mistake - in the rearrangement games (Fifteen, Sixteen, Twiddle) it's handy to be able to get your hands on a pristine grid quickly so you can practise or experiment with manoeuvres on it - it provides a good way of debugging the games if you think you've encountered an unsolvable grid! [originally from svn r5731]
* Introduce the concept of a `game_aux_info' structure. This isSimon Tatham2005-05-02
| | | | | | | | | | constructed at the same time as an internally generated game seed, so that it can preserve any interesting information known by the program at generation time but not physically contained within the text of the game seed itself. (Such as, for example, the solution.) Currently not used for anything yet, but it will be. [originally from svn r5729]
* Introduced a new function in every game which formats a game_stateSimon Tatham2005-05-01
| | | | | | | | as text. This is used by front ends to implement copy-to-clipboard. Currently the function does nothing (and is disabled) in every game except Solo, but it's a start. [originally from svn r5724]
* I can never remember what that `TRUE' means in the game structureSimon Tatham2005-05-01
| | | | | | | | | definitions, so let's move it so that it's just next to the functions it relates to. This also opens the way for me to add more booleans next to other functions without getting confused as to which is which. [originally from svn r5723]
* Arrange that we really _can_ compile all the puzzles into a singleSimon Tatham2005-01-22
| | | | | | | | binary if we choose: fix bugs in cube.c and sixteen.c that manifest when compiled that way, and introduce list.c which provides a global list of all the available puzzles. [originally from svn r5169]
* Rather than each game backend file exporting a whole load ofSimon Tatham2005-01-17
| | | | | | | | | | functions and a couple of variables, now each one exports a single structure containing a load of function pointers and said variables. This should make it easy to support platforms on which it's sensible to compile all the puzzles into a single monolithic application. The two existing platforms are still one-binary-per-game. [originally from svn r5126]
* Now we have the `dir' parameter, we should use it where it makesSimon Tatham2004-08-17
| | | | | | sense to do so. [originally from svn r4477]
* After discussion with Simon, the game redraw functions are now passed a newJacob Nevins2004-08-16
| | | | | | | | | argument `dir' which tells them whether this redraw is due to an undo, rather than have them second-guess it from game state. Note that none of the actual games yet take advantage of this; so it hasn't been tested in anger (although it has been inspected by debugging). [originally from svn r4469]
* Added a help file, mostly thanks to Jacob.Simon Tatham2004-08-16
| | | | [originally from svn r4460]
* Introduce routines in each game module to encode a set of gameSimon Tatham2004-05-19
| | | | | | | | | | | | parameters as a string, and decode it again. This is used in midend.c to prepend the game parameters to the game seed, so that copying out of the Specific box is sufficient to completely specify the game you were playing. Throughout development of these games I have referred to `seed' internally, and `game ID' externally. Now there's a measurable difference between them! :-) [originally from svn r4231]
* Framework alteration: we now support a `game_ui' structure inSimon Tatham2004-05-11
| | | | | | | | | | | | | addition to the `game_state'. The new structure is intended to contain ephemeral data pertaining to the game's user interface rather than the actual game: things stored in the UI structure are not restored in an Undo, for example. make_move() is passed the UI to modify as it wishes; it is now allowed to return the _same_ game_state it was passed, to indicate that although no move has been made there has been a UI operation requiring a redraw. [originally from svn r4207]
* GTK and Windows appear to handle timers very differently:Simon Tatham2004-05-03
| | | | | | | | | | | specifically, the elapsed time between calls varies much more with GTK than it does under Windows. Therefore, I now take my own time readings on every timer call, and this appears to have made the animations run at closer to the same speed between platforms. Having done that, I decided some of them were at the _wrong_ speed, and fiddled with each game's timings as well. [originally from svn r4189]
* The Windows RNG turns out to only give about 16 bits at a time. ThisSimon Tatham2004-05-03
| | | | | | | | | | | | | | | is (a) pretty feeble, and (b) means that although Net seeds transfer between platforms and still generate the same game, there's a suspicious discrepancy in the typical seed _generated_ by each platform. I have a better RNG kicking around in this code base already, so I'll just use it. Each midend has its own random_state, which it passes to new_game_seed() as required. A handy consequence of this is that initial seed data is now passed to midend_new(), which means that new platform implementors are unlikely to forget to seed the RNG because failure to do so causes a compile error! [originally from svn r4187]
* Implement selection of game seeds, by reusing the config boxSimon Tatham2004-05-03
| | | | | | | | | mechanism I've just invented (the midend handles the standard game selection configuration). Each game is now required to validate its own seed data before attempting to base a game on it and potentially confusing itself. [originally from svn r4186]
* `BOOLEAN' is a term already used by Win32. Bah. Change terminology.Simon Tatham2004-05-02
| | | | [originally from svn r4183]
* Configuration dialog box, on the GTK front end only as yet.Simon Tatham2004-05-01
| | | | [originally from svn r4182]
* The cube was being drawn slightly differently on the top and leftSimon Tatham2004-05-01
| | | | | | | | rows, because the coordinates were crossing one or other axis at that point and so the lower coordinate was being rounded up while the upper one was rounded down. Judicious use of floor() fixes it. [originally from svn r4179]
* We were forgetting to count the final move.Simon Tatham2004-04-30
| | | | [originally from svn r4176]
* Incorrect placing of the polyhedron sometimes left it on a blueSimon Tatham2004-04-30
| | | | | | square. Oops. [originally from svn r4175]
* Added a status bar.Simon Tatham2004-04-29
| | | | [originally from svn r4174]
* Implemented text and clipping primitives in the frontend, and addedSimon Tatham2004-04-29
| | | | | | two new simple games `fifteen' and `sixteen'. [originally from svn r4173]
* Add a new game concept called a `flash'. This is a graphical effectSimon Tatham2004-04-28
| | | | | | | | | | | | | | | taking non-zero time, which is triggered by the making of a move and is _not_ hurried to its conclusion by the start of the next move (so the game redraw function is expected to be able to draw it in parallel with continuing moves). The only thing that prematurely terminates a flash is the start of a fresh flash. In particular, this concept is used to display the completion flash in Net, because at least _my_ playing instincts make me lock every piece I've unambiguously placed, and hence the last turn move is instantly followed by a lock move which was previously suppressing the completion flash. [originally from svn r4168]
* Have each game declare a name which is used for window titles etc.Simon Tatham2004-04-28
| | | | [originally from svn r4167]
* Fix zillions of MSVC compiler warnings. Sigh.Simon Tatham2004-04-28
| | | | [originally from svn r4165]
* Introduce diagonal movement keys on the numeric keypad, and use themSimon Tatham2004-04-28
| | | | | | | | as an alternative control method in Cube. (This was a bit of hassle in the Windows front end; I also introduced a debugging framework and made TranslateMessage conditional.) [originally from svn r4162]
* Add a menu bar, in both Windows and GTK. In particular, game modulesSimon Tatham2004-04-28
| | | | | | | | | are now expected to provide a list of `presets' (game_params plus a name) which are selectable from the menu. This means I can play both Octahedron and Cube without recompiling in between :-) While I'm here, also enabled a Cygwin makefile, which Just Worked. [originally from svn r4158]
* Implemented Cube, in a sufficiently general way that it also handlesSimon Tatham2004-04-27
| | | | | | the tetrahedron, octahedron and icosahedron. [originally from svn r4151]
* Initial checkin of a portable framework for writing small GUI puzzleSimon Tatham2004-04-25
games. [originally from svn r4138]