Commit Graph
240 Commits
Author SHA1 Message Date
Denis Kasak 51cc821619 Added dialogue support.
svn-id: r43253
2009-08-11 04:03:22 +00:00
Denis Kasak abedc7e9bb Moved cursor state setting (when entering a new room) from Game::loadRoom() to Game::start() (just after running the gate program). This fixes a black cursor bug when the game starts (the cursor should not be even displayed then).
svn-id: r43162
2009-08-09 04:24:52 +00:00
Denis Kasak eeb72e3d0d * Implemented Game::loadWalkingMap().
* Extracted title updating from the main loop to a new method, Game::updateTitle().
* Added Game::updateCursor().
* Restructured the main loop to fix many subtle bugs and enable some new functionality concerning object scripts (like support for room-global use scripts).
* Added support for tracking currently selected icons (items, probably should be renamed).
* Changed walkDir, lookDir and useDir members of GameObject to int and adjusted them for zero-based indexing.
* Added Game::getCurrentIcon().
* Return from WalkingMap::findNearestWalkable immediately if the starting point is walkable.

svn-id: r43160
2009-08-09 04:09:24 +00:00
Denis Kasak c193c80e67 * Test whether an object can be used by evaluating its canUse script (warning: this will break many things currently working until I implement IsIcoAct in my next few commits).
* Removed old HACK note because look / use scripts are now more properly implemented.

svn-id: r43130
2009-08-08 16:17:21 +00:00
Denis Kasak d2f7268171 Removed TODO concerning the nearest walkable point feature and reworded some obsolete documentation.
svn-id: r43128
2009-08-08 15:53:47 +00:00
Denis Kasak 19d5d66fd7 * Implemented WalkingMap::findNearestWalkable() which mimics a heuristic from the original game that attempts to find walkable spots near the given point
* Implemented moving to the right place when looking / using objects.

svn-id: r43125
2009-08-08 12:31:49 +00:00
Denis Kasak 3ce16763c7 Enabled skipping the current line of text if a mouse click occurs.
svn-id: r43085
2009-08-06 05:17:18 +00:00
Denis Kasak 5ea44b9b5e Moved walkHero() (in the main loop) to the appropriate place (in anticipation of a smart finding a walkable point) and disabled walking during script execution / inventory.
svn-id: r43084
2009-08-06 05:04:21 +00:00
Denis Kasak 09e49a354f Turn off mouse cursor and disable titles when running look / use scripts.
svn-id: r43083
2009-08-06 04:50:37 +00:00
Denis Kasak da8bad0ef5 Made the game behave properly and safe when clicking on objects multiple times during talking or executing look/use scripts. Previously, the loop could be called nested arbitrarily many times.
svn-id: r43081
2009-08-06 03:52:08 +00:00
Denis Kasak e632106169 * Made some type changes to struct/class members in game.cpp (uint -> int and uint16 -> uint)
* Added enum constant kNoEscRoom for rooms that have no escape room defined
* Fixed crash when ESC is pressed in rooms which have no escape room defined
* Renamed kNotFound (used as a return value for Game::getObjectWithAnimation) to kObjectNotFound for clarity.

svn-id: r43072
2009-08-05 17:58:14 +00:00
Denis Kasak 6546c2ed8e * Added kTitleColour = 255 enum constant used in the following item.
* Added proper colouring of the title animation fonts
* Added Game::getEscRoom().

svn-id: r43063
2009-08-05 02:35:51 +00:00
Denis Kasak c9b24d2ff9 * Changed title text to use the small instead of the big font
* Handled title positioning
* Cleaned up the main loop a bit (comments, stylistic changes, shortened some lines, etc)
* Fixed setting the dragon's feet position (the x coordinate should be at the midpoint of the animation)

svn-id: r43059
2009-08-05 00:11:09 +00:00
Denis Kasak 41d7590835 * Reverted change that subtracts 1 from font colour indexes for various speaking characters; they are 0-based after all.
* Fixed font blitting algorithm to allow for both white fonts and transparency.

svn-id: r43044
2009-08-04 15:41:27 +00:00
Denis Kasak 5e2eefd4fe * Fixed bug which made characters talk with the wrong colour; the colour indexes are indexed from 1 in the data files so we need to subtract 1.
* Turned on font transparency again. 

svn-id: r43022
2009-08-03 01:48:15 +00:00
Denis Kasak f9bdd09659 * Fixed bug when reading in persons data. I was reading in coordinates as bytes and font colour as int16; it should be the other way around.
* Handled the kStatusTalk loop substatus properly inside Game::loop().
* Made Game::walkHero() set the person coordinates for the dragon after it warps him to a new location
* Added Game::getPerson() method (used by Script::talk())
* Added Game::setSpeechTick() method (set by Script::talk() and used inside the loop to determine when to switch to new text).

svn-id: r42994
2009-08-02 05:21:21 +00:00
Denis Kasak 014c33718f Added a dedicated animation for speech text.
svn-id: r42988
2009-08-02 03:02:22 +00:00
Denis Kasak e0e06fc9e0 * Made the engine set the appropriate loop status before running a gate program or entering the main loop
* Removed hack which ran programs for all gates when the room was changed

svn-id: r42977
2009-08-01 17:52:16 +00:00
Denis Kasak 5c6643f0f3 When changing rooms, set the first two game variables to the new room and gate number. Also, if the new room is the map room, set the appropriate coordinates for the dragon in the persons array.
svn-id: r42972
2009-08-01 03:26:39 +00:00
Denis Kasak 240871aa20 * Added support for loop substatus
* Set loop substatus to Ordinary when changing rooms

svn-id: r42971
2009-08-01 03:07:18 +00:00
Denis Kasak 18a8b5b3af * Added Game::runGateProgram()
* Added a separate mechanism to Game to keep track both of the current room number and the next room/gate. Periodically, I check whether the new room differs from the old one and, if it does, I do the change. Doing it any other would is nearly impossible because of the way the original scripts were written.
* Added GPL command Script::newRoom(). Rooms can now be traversed by clicking on their exits. Also, the intro animation partly works. Some parts go by far too soon. I assume this is because the engine still lacks a dialogue GPL command.
* Fixed bug where the gates array of a room was not cleared between uses.
* Save old jump value when we enter Script::run() and restore it in the end (mimicking the original engine).
* Fixed small bug where the gate was supposed to be stored as the first in-game variable and not the room number.

svn-id: r42957
2009-07-31 04:32:33 +00:00
Denis Kasak 167b6da230 * Woops, Game::getRoomNum() was already implemented. Removed the superfluous implementation.
* Set the first two game variables to the gate and room number in Game::init()
* Fixed compilation

svn-id: r42916
2009-07-30 03:43:44 +00:00
Denis Kasak 181b155a2f * Added support for keeping track of gates (exits from rooms)
* Added getters and setters for current room and gate numbers

svn-id: r42915
2009-07-30 03:37:04 +00:00
Denis Kasak 07042e31bc * Made Game::loop() exit conditionally depending on whether the internal Game::_shouldExitLoop variable is set.
* Added mechanisms for signalling whether the main game loop should exit or not (Game::setExitLoop() and Game::shouldExitLoop())

svn-id: r42899
2009-07-29 19:38:02 +00:00
Denis Kasak e9669b8e2b * Moved event handling to DraciEngine::handleEvents()
* Added Game::start() method which is called from DraciEngine::go()
* Made Game::loop() suitable for calling from other places (like GPL scripts) by handling events, redrawing the screen, etc from inside. This way it doesn't freeze the game if it doesn't return immediately.
* Added Game::shouldQuit() and Game::setQuit() which can be used to signal the engine to quit.
* Fixed race condition related to mouse buttons not getting released.
* Instead of deleting frames for the title animation and adding a new one, reset the text for its frame.

svn-id: r42875
2009-07-29 01:11:53 +00:00
Denis Kasak 5a44af4433 Enabled running of look/use scripts on left/right mouse button press for testing (Warning: unstable in some places).
svn-id: r42841
2009-07-27 05:34:22 +00:00
Denis Kasak 019b7f310b * Added Game::getObjectWithAnimation() which finds the object that owns an animation with a certain ID
* Made GameObjects track their titles as Strings rather than byte *
* Made the engine display the title of the object under the cursor (added a special animation ID for that, kTitleText)

svn-id: r42839
2009-07-27 04:51:34 +00:00
Denis Kasak 6970e178dc Replaced magic constant with enum kWalkingMapOverlay.
svn-id: r42778
2009-07-25 18:29:43 +00:00
Denis Kasak 20baaf93f5 * Moved walking code to Game::walkHero().
* Implemented WalkOn GPL command.
* Temporarily remaped StayOn and WalkOnPlay to WalkOn (for testing).

svn-id: r42735
2009-07-25 04:36:43 +00:00
Denis Kasak d28658984d * Added DraciEngine::_initArchive and made Game use it. Fixes a memory bug because Game uses pointers from the init archive which should outlive it (but didn't previously).
* Added support for setting loop status to Game.
* Made some GPL commands check whether we are in the correct loop status before executing.

svn-id: r42731
2009-07-25 03:28:04 +00:00
Denis Kasak 5faceb595f Temporary mapped GPL command StartPlay to handler for Start and reenabled gates' scripts (for added effects and testing).
svn-id: r42684
2009-07-24 05:07:27 +00:00
Denis Kasak c1ad0c3926 * Added tracking and deleting animations by index (which represents the order in which they were loaded). This is needed by some GPL commands.
* Added Game::getNumObjects() which returns the number of objects in the game
* Fixed segfault (accessing a null Animation *)
* Added some docs to various things

svn-id: r42683
2009-07-24 05:00:53 +00:00
Denis Kasak a2bca06b3f Added support for per-animation scaling (via scaling factors). I have decided to go for a mixed approach (where Animation has a global scaling factor for the whole animation which is separate from Drawable's scaled width and height) so the animation can be scaled more naturally when the scale often changes (like with perspective when the dragon is walking). Previously, one had to alter the sizes of each frame of the dragon's animation whenever the dragon moved which was unclean.
svn-id: r42680
2009-07-24 01:54:13 +00:00
Denis Kasak 1726cc8d24 * Disabled unconditional execution of gates' scripts
* Fixed bug in Animation::nextFrame() which caused non-looping animations to linger on forever
* Stopped setting looping to false explicitly in AnimationManager::addAnimation() since the Animation constructor already does that

svn-id: r42657
2009-07-22 11:30:57 +00:00
Eugene Sandulenko 1c86a986d9 Fix warnings
svn-id: r42653
2009-07-22 07:22:12 +00:00
Denis Kasak ef37d0a9b0 * Stopped AnimationManager::drawScene() from marking its own dirtiness.
* Instead, Animation::nextFrame() marks both the old and the new frame dirty. This makes it possible to only update the real screen when the animation changes and results in a pretty big speedup.
* Added utility method Animation::markDirtyRect() which takes a (Surface *) and marks a dirty rect on it for the current frame.
* Fixed artifacts when moving the dragon.

svn-id: r42652
2009-07-22 07:18:00 +00:00
Denis Kasak 42e8e1e126 If a frame has scaled dimensions set to 0, the engine now does no scaling instead of scaling it to nothing. Fixes the disappearing chair bug.
svn-id: r42650
2009-07-22 05:00:11 +00:00
Denis Kasak b3a2d186bb * Moved scaling support from Animation to Sprite
* Now each Sprite (and hence frame in an animation) can have a separate zoom (which is needed for some animations in the game)
* Scale factors are not stored any more; instead, we only store scaled dimensions (since these are stored in the data files) and calculate the factors from those.

svn-id: r42647
2009-07-22 04:42:33 +00:00
Denis Kasak 6097828f54 Made 'show walking map overlay' setting persist when changing rooms.
svn-id: r42628
2009-07-20 17:34:19 +00:00
Denis Kasak a2a71cb8fb * Added scaling support
* Made the dragon scale when it is in different parts of the room
* Added getters for relative coordinates (Animation::getRelativeX() and Animation::getRelativeY())
* Commented Game::loop() and Sprite::draw*() methods in more detail

svn-id: r42627
2009-07-20 17:25:57 +00:00
Denis Kasak 18301b6f78 * Used ldexp() in real_to_double() instead of doing the calculation manually
* Moved static declaration of real_to_double() to game.cpp

svn-id: r42616
2009-07-19 14:54:16 +00:00
Denis Kasak 1ec375bbd5 Added capability for reading in Pascal 6-byte floats and made Game::loadRoom() read in pers0 and persStep correctly.
svn-id: r42612
2009-07-19 13:28:05 +00:00
Denis Kasak 128fe6ea21 Made the engine handle the Z coordinate for the hero properly.
svn-id: r42584
2009-07-18 03:20:26 +00:00
Denis Kasak 10e9a780ce Made the engine stop the dragon animation when the room changes.
svn-id: r42583
2009-07-18 03:12:12 +00:00
Denis Kasak 18fda1b2f3 Fixed a bug where the cursor was not shown when the first room is loaded and has mouse enabled.
svn-id: r42582
2009-07-18 03:05:20 +00:00
Denis Kasak 94417e7743 * Added support for "walking" with the hero (i.e. moving the sprite to locations allowed by the walking map)
* Enabled drawing the walking map with the 'w' hotkey for testing

svn-id: r42581
2009-07-18 03:00:12 +00:00
Denis Kasak aa82c39857 * Made Game::changeRoom() clear some more archives
* Modified the engine to leverage BArchive's memory management capabilities by using its pointers to data directly instead of copying
* Removed GameObject destructor (not needed because of the above change)
* Changed some more data members from uint16 to uint

svn-id: r42555
2009-07-17 01:20:51 +00:00
Denis Kasak 8018216dea * Renamed Room::_numMasks to _numOverlays for consistency.
* Fixed unsigned to signed comparison.

svn-id: r42549
2009-07-17 00:27:21 +00:00
Denis Kasak e419110569 * Added Game::loop()
* Added WalkingMap::isWalkable()
* Renamed remaining _priority identifiers to _z which were left by mistake in the previous commit

svn-id: r42546
2009-07-17 00:20:57 +00:00
Denis Kasak c420a4fba1 Renamed GameObject::_priority to _z.
svn-id: r42542
2009-07-16 18:39:39 +00:00