Commit Graph
608 Commits
Author SHA1 Message Date
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 0098084969 Fixed one more bug related to animations having no frames.
svn-id: r42838
2009-07-27 04:47:38 +00:00
Denis Kasak aa6efa33f1 Fixed segfault when the screen is deleted before animations (the Animation destructor still needs to use the screen).
svn-id: r42837
2009-07-27 04:20:27 +00:00
Denis Kasak 673bae4443 * Added AnimationManager::addText() for adding text animations
* Added AnimationManager::getTopAnimationID(x, y) which returns the ID of the top layer animation located on a point
* Added Animation::getScale{X,Y}()
* Fixed a few bugs related to animations sometimes having no frames

svn-id: r42836
2009-07-27 04:18:44 +00:00
Denis Kasak fa59e4b16b * Added Sprite::getPixel() (takes into account whether a sprite is mirrored or scaled)
* Made the Text class internally store a Common::String instead of a byte *

svn-id: r42835
2009-07-27 04:14:59 +00:00
Denis Kasak ddf8f1cbb5 * Removed unused variable
* Fixed unsigned to signed comparison warning

svn-id: r42834
2009-07-27 03:57:43 +00:00
Denis Kasak b14828c4ce * Added Font::getStringHeight()
* Made Font::getStringWidth() calculate the width of the string properly now that handling of multi-row strings is in
* Fixed bug which caused the last column of pixels in the last letter of a string to linger on the screen

svn-id: r42832
2009-07-27 03:08:19 +00:00
Denis Kasak 2525ec46de * Removed friend declarations in Drawable for Sprite and Text, and made Drawable's private members protected so they can access them
* Added Text::drawScaled() and altered Text::getRect() so Text instances can be accessed through a Drawable pointer. Scaling text is planned for later because it's not essential.

svn-id: r42789
2009-07-26 00:04:12 +00:00
Denis Kasak 3f571c7eae Handled the '|' char correctly when drawing text (it serves as both a newline and end-of-string marker).
svn-id: r42788
2009-07-25 23:43:21 +00:00
Denis Kasak 20a744bdd2 Simplified rectangle height and width calculation in Sprite::drawScaled() (use methods of Common::Rect instead of doing it manually).
svn-id: r42779
2009-07-25 18:33:20 +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 22c372137f Added Movement enum that enumerates the animations for the dragon's movement.
svn-id: r42734
2009-07-25 04:23:59 +00:00
Denis Kasak ceb9f18132 Made Script::run() manually mark the last animation index before it executes a program. This is done to prevent Release wreaking havoc if it is unpaired (i.e. if the script forgot to call a Mark first).
svn-id: r42733
2009-07-25 03:41:28 +00:00
Denis Kasak ed59a12d53 Implemented ExecUse, ExecLook and ExecInit GPL commands.
svn-id: r42732
2009-07-25 03:37:22 +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 b7e97efb7f * Added handlers for the ObjStat and ObjStat_On GPL commands
* Removed temporary hack I accidentally committed

svn-id: r42730
2009-07-25 02:23:00 +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 5a77f089e1 Check whether the walking map overlay is already in the desired state so we don't start/stop it over and over.
svn-id: r42651
2009-07-22 05:03:34 +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 9b32771017 Fixed scaled mirrored sprite drawing. This change enables the NoSense logo animation to be played correctly.
svn-id: r42649
2009-07-22 04:50:11 +00:00
Denis Kasak 348cbc2b19 * Removed some unnecessary virtual qualifiers from methods in Drawable, Sprite and Text.
* Changed some Drawable members from uint16 to uint.
* Added some const qualifiers to methods of Drawable.

svn-id: r42648
2009-07-22 04:47:01 +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 cb185f18cd Fixed bug which caused the dragon to be animated with the wrong Z coordinate for short periods of time when moved to a new location.
svn-id: r42586
2009-07-18 12:08:18 +00:00
Denis Kasak a44cda5525 Fixed bug which caused animations to sometimes be played too fast if the engine was busier than usual (like when redrawing the whole screen when returning from minimized state).
svn-id: r42585
2009-07-18 05:21:01 +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 3cde84fec4 Fixed bug where certain animations were played very fast when not played immediately when they are created.
svn-id: r42580
2009-07-18 02:58:11 +00:00
Denis Kasak adf9e91e1f * Added Animation::getFrame()
* Added support for sorting animations when Z is changed later on (AnimationManager::sortAnimations())
* Added support for relative coordinates (Animation::setRelative())
* Fixed bug where AnimationManager::deleteOverlays() deleted all animations

svn-id: r42579
2009-07-18 02:53:37 +00:00
Denis Kasak 8e1f296308 Removed room switching hack from Mouse and re-added it to DraciEngine::go() (right arrow switches to the next room, left to the previous.
svn-id: r42577
2009-07-18 01:11:45 +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 16530846ac * Renamed BAFile::closeFile() to close()
* Fixed leak in BArchive::loadFileDFW()

svn-id: r42554
2009-07-17 01:05:13 +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 cfa4d5eba0 Added sanity checks for all archives (whether opening succeeded).
svn-id: r42547
2009-07-17 00:24:56 +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
Denis Kasak 652acfc4ca * Added WalkingMaps class
* Added DraciEngine::walkingMapsArchive
* Made Game::loadRoom() read in the current walking map

svn-id: r42541
2009-07-16 18:31:15 +00:00
Denis Kasak e031709989 Added _iconsArchive to DraciEngine and modified the Mouse class to use it.
svn-id: r42535
2009-07-16 16:06:29 +00:00
Denis Kasak 3d36ad3e67 Fixed loading the location's walking map index (needed to subtract 1).
svn-id: r42534
2009-07-16 15:00:46 +00:00