Commit Graph

214 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
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
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
3d36ad3e67 Fixed loading the location's walking map index (needed to subtract 1).
svn-id: r42534
2009-07-16 15:00:46 +00:00
Denis Kasak
1bf574aaa9 Added proper cursor state handling (when in rooms that don't use the mouse). Added a HACK note for running the gates' scripts.
svn-id: r42532
2009-07-16 12:07:41 +00:00
Denis Kasak
ffffc1bea4 * Changed Game members _numMasks, _init, _look, _use and _canUse from uint16 to int
* Modified Game::loadRoom to load gates and execute their scripts
* The first room loaded is now Game::_info._startRoom instead of 0
* Fixed reading of _pers0 and _persStep from the data files (they are 6 instead of 12 bytes)
* Added more debug info to Script and Game

svn-id: r42515
2009-07-15 19:06:24 +00:00
Denis Kasak
4ef46f4bb0 Adjusted levels for some Game debug messages and added some new ones.
svn-id: r42489
2009-07-14 19:13:49 +00:00
Denis Kasak
d5e1611846 Renamed GameInfo::_currentRoom to _startRoom to better reflect its purpose.
svn-id: r42465
2009-07-14 00:51:35 +00:00
Denis Kasak
25b884512d Made Game allocate its _info member statically instead of dinamically.
svn-id: r42464
2009-07-14 00:41:17 +00:00
Denis Kasak
04e4bfdbbe * Implemented the following GPL functions: IsIcoOn, IcoStat, IsObjOn, IsObjOff, IsObjAway
* Changed GameObject::_location to an int since we sometimes use location -1.
* Some more uint <-> int changes to prevent comparisons between signed and unsigned.

svn-id: r42452
2009-07-13 19:53:53 +00:00
Denis Kasak
f8c20b9e9c Renamed Game::_itemStatus to _iconStatus. Added an assert to check if the number of icons is correct.
svn-id: r42449
2009-07-13 19:24:22 +00:00
Denis Kasak
77a810c0c9 Moved the delay mechanism from Animation to Drawable since each frame in an animation can have a different delay.
svn-id: r42427
2009-07-12 19:32:01 +00:00
Denis Kasak
d369a257d1 Enabled clearing the screen when the room changes since some rooms do not draw anything on some parts of the screen.
svn-id: r42425
2009-07-12 19:00:24 +00:00
Denis Kasak
32d692aea6 Made the engine clear some more caches when it changes rooms (room, sprites and palette caches). Made the DraciEngine destructor delete the rooms, overlays and animations archives.
svn-id: r42250
2009-07-08 00:40:22 +00:00
Denis Kasak
dd955bb08e * Made Game::_variables private and, instead, added Game::{get,set}Variable() methods.
* Removed obsolete comment about the cyclic field not being used in Game::loadAnimation()

svn-id: r42246
2009-07-07 21:30:36 +00:00
Denis Kasak
586af0ab42 * From Game::GameObject removed the following _idxSeq, _numSeq, _animObj, _seqTab (not used anymore), added Common::Array<int> _anims.
* Handled cylic animations properly
* Handled the Z coordinate properly

svn-id: r42244
2009-07-07 21:18:28 +00:00
Denis Kasak
b6b1402368 * Changed Game::_variables to public since the GPL interpreter needs to use it and made it int instead of uint16
* Implemented variable accessing by the math evaluator
* Fixed bug from previous commit (should have used && when checking for ending instructions, not ||)

svn-id: r42242
2009-07-07 20:57:14 +00:00
Denis Kasak
d37d49e50c Removed testing hack from Game::init() that displayed the dragon in the upper left corner. Replaced some more instances of magic numbers with kDragonObject. Made Game::init() a bit more readable.
svn-id: r42237
2009-07-07 19:53:40 +00:00
Denis Kasak
fd2ab9e3c0 Added enum constant for the dragon object (kDragonObject) and made Script::start() a bit more readable.
svn-id: r42236
2009-07-07 19:50:12 +00:00
Denis Kasak
2e552bf643 Stopped running the room init scripts twice.
svn-id: r42225
2009-07-07 15:31:13 +00:00
Denis Kasak
7f3af129f2 mplemented changing rooms properly (overlays and objects' animations are deleted before a new room is loaded) and set up a quick demonstration (left click advances to the next room, right click goes back).
svn-id: r42224
2009-07-07 15:21:41 +00:00
Denis Kasak
79c42abf08 * Fixed extracting visibility and location of object from its status byte
* Added Game::getRoomNum() which returns the current room number
* Made Game::loadRoom() execute the room's startup script, load the room's objects and run their init scripts as well

svn-id: r42194
2009-07-06 19:50:59 +00:00
Denis Kasak
8e341ee968 Renaming Animation -> AnimationManager and AnimObj -> Animation in light of the new API change.
svn-id: r42133
2009-07-05 11:52:17 +00:00
Denis Kasak
6c3e9f5151 * API change for Animation and AnimObj; AnimObj is now a proper class and each instance handles its own animation. Animation handles adding, fetching and deleting of AnimObjs (probably needs a namechange).
* Implemented actual animation (previously only the first frame was display)
* Implemented animation starting, stoping, looping
* Loaded looping dragon animation as a test

svn-id: r42114
2009-07-05 03:24:46 +00:00
Denis Kasak
960740fe83 Rewrote Sprite::draw() to draw overflowing sprites correctly. Stopped playing animations as soon as they're loaded from Game::loadAnimation().
svn-id: r42111
2009-07-04 23:05:13 +00:00
Denis Kasak
b96b434446 * Added Game::init() and moved some functionality from Game::Game to it (loading objects, changing rooms)
* Made Game::load*(), Game::getObject() and Game::changeRoom() methods public
* Stopped specifying Z coordinate when creating some Sprites (which I forgot in my previous commit)

svn-id: r42101
2009-07-04 18:35:08 +00:00
Denis Kasak
0888e8a6da * Split code from Game::changeRoom() into Game::loadRoom() and game::loadOverlays(). Game::changeRoom() now calls them instead.
* Added Game::loadAnimation()
* The engine now stores "real" indexes (zero-based) instead of Pascal's because the previous approach was messy. 

svn-id: r42092
2009-07-04 15:21:12 +00:00
Denis Kasak
c651d1c2e2 Made Game::changeRoom() clear the overlaysArchive cache when it's done loading overlays.
svn-id: r42072
2009-07-03 18:17:05 +00:00
Denis Kasak
1853d594b8 Enabled loading room number 1 as a test.
svn-id: r42071
2009-07-03 17:55:28 +00:00
Denis Kasak
4ba1ea8adf Added support for loading room overlays to Game::changeRoom().
svn-id: r42070
2009-07-03 17:54:13 +00:00
Denis Kasak
8bba3e6f10 Added Game::changeRoom() method and Game::_currentRoom.
svn-id: r42036
2009-07-02 20:29:14 +00:00
Denis Kasak
cac39d8295 Added rooms and overlays archives.
svn-id: r42035
2009-07-02 19:57:09 +00:00
Denis Kasak
be3c0461d6 DraciEngine now opens and stores pointers to essential archives. Changed code that used those archives to use that instead of opening them manually. Replaced BArchive::operator[] functionality with BArchive::getFile() to prevent ugliness when accessing archives via pointers.
svn-id: r42031
2009-07-02 16:15:32 +00:00
Denis Kasak
936e5f4c5e Merged the info available from _objectStatus with the GameObject struct. Made Game keep a list of all the game's objects. Added Game::getObject() method for fetching a pointer to a particular object. Changed Game::loadObject() to not accept a pointer to a GameObject struct anymore.
svn-id: r42026
2009-07-02 15:08:42 +00:00
Denis Kasak
138d17bbab Changed some data members in Draci::GameInfo from uint32 to uint16 (previously I thought that the 'word' type in the original engine was 32 bits). Removed a FIXME concerning struct size mismatch (matches when the previous sentence is taken into account). GameInfo::_numDialogBlocks is now calculated, not read in (it wasn't stored in the data files at all).
svn-id: r41966
2009-06-29 22:27:38 +00:00
Denis Kasak
63aa2b7aaf Account for endianess properly when reading in game variables.
svn-id: r41965
2009-06-29 22:20:30 +00:00
Denis Kasak
6a78781889 Added an offset parameter to Script::run() so we can specify where to start the GPL program execution. Also, the init script for the dragon object is now run inside Game::Game().
svn-id: r41928
2009-06-28 16:28:16 +00:00
Denis Kasak
f61b2d289d Changed Script::run() to accept a GPL2Program struct instead of a byte pointer and a length. Also, Script::run() now executes the GPL program until a gplend instruction rather than to the end of the whole program. Modified GameObject according to the new changes.
svn-id: r41927
2009-06-28 16:19:10 +00:00
Denis Kasak
d28bbe51bf Added struct GameObject (such structs are stored in OBJEKTY.DFW and used for in-game objects' info). Added Game::loadObject() for loading such objects into memory. Made Game's constructor load the object for the main hero.
svn-id: r41925
2009-06-28 13:10:53 +00:00
Denis Kasak
746e2214ee Extended Game to load all info from INIT.DFW (general game info, dialog offsets, variables, item status, object status).
svn-id: r41908
2009-06-27 05:10:24 +00:00
Denis Kasak
0430939006 Added Game's constructor. Added the Person struct and made Game constructor read in the list of persons from INIT.DFW. Added Game instance to DraciEngine.
svn-id: r41907
2009-06-27 01:04:24 +00:00
Denis Kasak
c1644493b8 Added empty Game class.
svn-id: r41906
2009-06-26 23:34:06 +00:00