-
-
Notifications
You must be signed in to change notification settings - Fork 565
New object: Enemy Blocker #457
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5e5804d
Create enemy_blocker.cpp
9c08402
Create enemy_blocker.hpp
6498e88
Update object_factory.cpp
b6e8e9b
Update enemy_blocker.cpp
7dbc627
Update enemy_blocker.hpp
cf12944
Add method "collides" to enemy_blocker.cpp
15ea314
Add method "collides" to enemy_blocker.hpp
ed907ce
Update input_center.cpp
37f3769
Reverted changes
30ccb92
Reverted change in another file
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| // SuperTux | ||
| // Copyright (C) 2007 Kovago Zoltan <[email protected]> | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| #include "object/enemy_blocker.hpp" | ||
|
|
||
| #include "editor/editor.hpp" | ||
| #include "badguy/badguy.hpp" | ||
| #include "supertux/object_factory.hpp" | ||
| #include "util/gettext.hpp" | ||
| #include "util/reader_mapping.hpp" | ||
| #include "video/drawing_context.hpp" | ||
|
|
||
| EnemyBlocker::EnemyBlocker(const ReaderMapping& lisp): | ||
| width(), | ||
| height() | ||
| { | ||
| if (!lisp.get("name" , name)) name = ""; | ||
| if (!lisp.get("x", bbox.p1.x)) bbox.p1.x = 0; | ||
| if (!lisp.get("y", bbox.p1.y)) bbox.p1.y = 0; | ||
| if (!lisp.get("width", width)) width = 32; | ||
| if (!lisp.get("height", height)) height = 32; | ||
|
|
||
| bbox.set_size(width, height); | ||
| } | ||
|
|
||
| ObjectSettings | ||
| EnemyBlocker::get_settings() { | ||
| width = bbox.get_width(); | ||
| height = bbox.get_height(); | ||
|
|
||
| ObjectSettings result = MovingObject::get_settings(); | ||
| result.options.push_back( ObjectOption(MN_NUMFIELD, _("Width"), &width, "width")); | ||
| result.options.push_back( ObjectOption(MN_NUMFIELD, _("Height"), &height, "height")); | ||
|
|
||
| return result; | ||
| } | ||
|
|
||
| void | ||
| EnemyBlocker::after_editor_set() { | ||
| bbox.set_size(width, height); | ||
| } | ||
|
|
||
| HitResponse | ||
| EnemyBlocker::collision(GameObject& other, const CollisionHit& ) | ||
| { | ||
| BadGuy* badguy = dynamic_cast<BadGuy*> (&other); | ||
|
|
||
| if (badguy == 0) | ||
| return ABORT_MOVE; | ||
| return FORCE_MOVE; | ||
| } | ||
|
|
||
| void | ||
| EnemyBlocker::draw(DrawingContext& context) | ||
| { | ||
| if (Editor::is_active()) { | ||
| context.draw_filled_rect(bbox, Color(0.96f, 0.38f, 0.0f, 0.8f), | ||
| 0.0f, LAYER_OBJECTS); | ||
| } | ||
| } | ||
|
|
||
| void | ||
| EnemyBlocker::update(float ) | ||
| { | ||
| } | ||
|
|
||
| /* EOF */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| // SuperTux | ||
| // Copyright (C) 2007 Kovago Zoltan <[email protected]> | ||
| // | ||
| // This program is free software: you can redistribute it and/or modify | ||
| // it under the terms of the GNU General Public License as published by | ||
| // the Free Software Foundation, either version 3 of the License, or | ||
| // (at your option) any later version. | ||
| // | ||
| // This program is distributed in the hope that it will be useful, | ||
| // but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| // GNU General Public License for more details. | ||
| // | ||
| // You should have received a copy of the GNU General Public License | ||
| // along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
|
|
||
| #ifndef HEADER_SUPERTUX_OBJECT_ENEMY_BLOCKER_HPP | ||
| #define HEADER_SUPERTUX_OBJECT_ENEMY_BLOCKER_HPP | ||
|
|
||
| #include "supertux/moving_object.hpp" | ||
| #include "util/reader_fwd.hpp" | ||
|
|
||
| /** An object that only solid for badguys. */ | ||
| class EnemyBlocker : public MovingObject | ||
| { | ||
| public: | ||
| EnemyBlocker(const ReaderMapping& lisp); | ||
|
|
||
| HitResponse collision(GameObject& other, const CollisionHit& hit); | ||
|
|
||
| void draw(DrawingContext& context); | ||
|
|
||
| std::string get_class() const { | ||
| return "enemy_blocker"; | ||
| } | ||
| std::string get_display_name() const { | ||
| return _("Enemy blocker"); | ||
| } | ||
|
|
||
| virtual ObjectSettings get_settings(); | ||
| virtual void after_editor_set(); | ||
|
|
||
| private: | ||
| void update(float elapsed_time); | ||
|
|
||
| float width, height; | ||
| }; | ||
|
|
||
| #endif | ||
|
|
||
| /* EOF */ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you use the method "collides" in addition?