Skip to content

Commit

Permalink
Add rotate and getRotation ( WIP ) commands
Browse files Browse the repository at this point in the history
Optimization for drawing
  • Loading branch information
MackValentine committed Oct 14, 2024
1 parent 991eff2 commit 82966ad
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 61 deletions.
29 changes: 29 additions & 0 deletions src/game_interpreter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -828,6 +828,10 @@ bool Game_Interpreter::ExecuteCommand(lcf::rpg::EventCommand const& com) {
return CommandManiacCallCommand(com);
case 9901:
return Command3DPicture(com);
case 9902:
return Command3DPictureRotate(com);
case 9903:
return CommandGet3DPictureRotate(com);
default:
return true;
}
Expand Down Expand Up @@ -5180,3 +5184,28 @@ bool Game_Interpreter::Command3DPicture(lcf::rpg::EventCommand const& com) {

return true;
}

bool Game_Interpreter::Command3DPictureRotate(lcf::rpg::EventCommand const& com) {
int picID = ValueOrVariable(com.parameters[0], com.parameters[1]);
int rotX = ValueOrVariable(com.parameters[2], com.parameters[3]);
int rotY = ValueOrVariable(com.parameters[4], com.parameters[5]);
int rotZ = ValueOrVariable(com.parameters[6], com.parameters[7]);

Main_Data::game_pictures->Rotate3D(picID, rotX, rotY, rotZ);

return true;
}

bool Game_Interpreter::CommandGet3DPictureRotate(lcf::rpg::EventCommand const& com) {
int picID = ValueOrVariable(com.parameters[0], com.parameters[1]);
int varX = ValueOrVariable(com.parameters[2], com.parameters[3]);
int varY = ValueOrVariable(com.parameters[4], com.parameters[5]);
int varZ = ValueOrVariable(com.parameters[6], com.parameters[7]);

// Output::Debug(" {} {} {}", varX, varY, varZ);

Main_Data::game_pictures->Get3DRotation(picID, varX, varY, varZ);

return true;
}

2 changes: 2 additions & 0 deletions src/game_interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ class Game_Interpreter
bool CommandManiacControlStrings(lcf::rpg::EventCommand const& com);
bool CommandManiacCallCommand(lcf::rpg::EventCommand const& com);
bool Command3DPicture(lcf::rpg::EventCommand const& com);
bool Command3DPictureRotate(lcf::rpg::EventCommand const& com);
bool CommandGet3DPictureRotate(lcf::rpg::EventCommand const& com);

int DecodeInt(lcf::DBArray<int32_t>::const_iterator& it);
const std::string DecodeString(lcf::DBArray<int32_t>::const_iterator& it);
Expand Down
26 changes: 25 additions & 1 deletion src/game_pictures.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ void Game_Pictures::Picture::Update(bool is_battle) {
}

if (pic3D != nullptr) {
pic3D->Update();
pic3D->Update(false);
sprite->SetBitmap(pic3D->sprite);
}
}
Expand Down Expand Up @@ -667,6 +667,16 @@ void Game_Pictures::Show3D(std::string n, int picID, int zoom, int dx, int dy, i
pic.Show3D(n, zoom, dx, dy, rx, ry, rz);
}

void Game_Pictures::Rotate3D(int picID, int rx, int ry, int rz) {
auto& pic = GetPicture(picID);
pic.Rotate3D(rx, ry, rz);
}

void Game_Pictures::Get3DRotation(int picID, int vx, int vy, int vz) {
auto& pic = GetPicture(picID);
pic.Get3DRotation(vx, vy, vz);
}

void Game_Pictures::Picture::Show3D(std::string n, int zoom, int dx, int dy, int rx, int ry, int rz) {
pic3D = new Spriteset_MapDoom(n, zoom, dx, dy, rx, ry, rz);

Expand All @@ -675,3 +685,17 @@ void Game_Pictures::Picture::Show3D(std::string n, int zoom, int dx, int dy, int
needs_update = true;
}
}

void Game_Pictures::Picture::Rotate3D(int rx, int ry, int rz) {
if (pic3D) {
pic3D->setRotation(rx, ry, rz);
}
}

void Game_Pictures::Picture::Get3DRotation(int vx, int vy, int vz) {
if (pic3D) {
pic3D->getRotation(vx, vy, vz);
}
}


4 changes: 4 additions & 0 deletions src/game_pictures.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ class Game_Pictures {
bool Show(int id, const ShowParams& params);
void Move(int id, const MoveParams& params);
void Show3D(std::string n, int picID, int zoom, int dx, int dy, int rx, int ry, int rz);
void Rotate3D(int picID, int rx, int ry, int rz);
void Get3DRotation(int picID, int vx, int vy, int vz);
void Erase(int id);
void EraseAll();

Expand Down Expand Up @@ -132,6 +134,8 @@ class Game_Pictures {
bool IsWindowAttached() const;

void Show3D(std::string n, int zoom, int dx, int dy, int rx, int ry, int rz);
void Rotate3D(int rx, int ry, int rz);
void Get3DRotation(int vx, int vy, int vz);
Spriteset_MapDoom* pic3D = nullptr;
};

Expand Down
2 changes: 1 addition & 1 deletion src/spriteset_map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void Spriteset_Map::Update() {
}

void Spriteset_Map::doomUpdate() {
doom->Update();
doom->Update(true);
doom_lower->SetBitmap(doom->sprite);
doom_upper->SetBitmap(doom->spriteUpper);
}
Expand Down
Loading

0 comments on commit 82966ad

Please sign in to comment.