Code Monkey home page Code Monkey logo

Comments (16)

jhawz avatar jhawz commented on August 16, 2024

void GameObjectManager::checkIfActorFired(VisibleGameObject* obj) {
std::cout << obj->getFiring() << std::endl;
if (obj->getFiring() == true) {
Bullet *bullet;
if (obj->isFacingRight()) {
bullet = new Bullet("actors.xml", "textures/JB.png", 0);
bullet->SetPosition(obj->GetPosition().x, obj->GetPosition().y);
bullet->setBoundary(obj->GetPosition().x + 400,
obj->GetPosition().x - 400);
} else {
bullet = new Bullet("actors.xml", "textures/JB.png", 1);
bullet->SetPosition(obj->GetPosition().x, obj->GetPosition().y);
bullet->setBoundary(obj->GetPosition().x + 400,
obj->GetPosition().x - 400);
}

    Add("Bullet", bullet);
    obj->setFiring(false);
}

}

from cs420-project.

Jagabel avatar Jagabel commented on August 16, 2024

Looks like no texture rect is being set...is there a bullet entry in the
config file?

On Thursday, November 20, 2014, Joe Hause [email protected] wrote:

Code in GameObjectManager

void GameObjectManager::checkIfActorFired(VisibleGameObject* obj) {
std::cout << obj->getFiring() << std::endl;
if (obj->getFiring() == true) {
Bullet *bullet;
if (obj->isFacingRight()) {
bullet = new Bullet("actors.xml", "textures/JB.png", 0);
bullet->SetPosition(obj->GetPosition().x, obj->GetPosition().y);
bullet->setBoundary(obj->GetPosition().x + 400,
obj->GetPosition().x - 400);
} else {
bullet = new Bullet("actors.xml", "textures/JB.png", 1);
bullet->SetPosition(obj->GetPosition().x, obj->GetPosition().y);
bullet->setBoundary(obj->GetPosition().x + 400, 0);
}

Add("Bullet", bullet);
obj->setFiring(false);

}

}


Reply to this email directly or view it on GitHub
#44 (comment).

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

Yes there is a Bullet entry. There is a set texture rect in there. For some reason the Update function on Bullet is not getting called once the bullet has been placed in the game manager. I'm looking at it now. Thanks for checking it out man 👍

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

Ok, now I don't think that is the problem anymore. Not sure what is causing this...

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

@freegyp did you actually test that the bullet gets drawn properly and fires properly?

from cs420-project.

Jagabel avatar Jagabel commented on August 16, 2024

Got it. In the constructor for the Bullet class add in this line:

type = 4;

Let me know if that works.

On Friday, November 21, 2014, Joe Hause [email protected] wrote:

Ok, now I don't think that is the problem anymore. Not sure what is
causing this...


Reply to this email directly or view it on GitHub
#44 (comment).

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

The full sheet moves forward and then disappears so that is something different.

from cs420-project.

Jagabel avatar Jagabel commented on August 16, 2024

Hm...my code shouldn't cause it to disappear or pop up as an entire
sheet...is there a death method or something similar being triggered?

On Friday, November 21, 2014, Joe Hause [email protected] wrote:

The full sheet moves forward and then disappears so that is something
different.


Reply to this email directly or view it on GitHub
#44 (comment).

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

This piece of code in Bullet.cpp was killing it. With that commented out, the whole sheet appears for a second and then disapears leaving the bullet to go accross the screen.

    if (pos.x+vx*elapsedTime<=leftBoundary||pos.x+vx*elapsedTime>=rightBoundary) {
        animReq("disappear");
        to_delete=true;
    }

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

I set the boundary in the checkIfActorFired function in GameObjectManager as (but still does this if boundary is not set):

       bullet->setBoundary(obj->GetPosition().x + 400,
                obj->GetPosition().x - 400);

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

Still doesn't explain why the whole sheet is getting drawn at first though.

from cs420-project.

Jagabel avatar Jagabel commented on August 16, 2024

The texture rect is modified as result of movement, but not with the
constructor...causes a second or so of the entire sheet being drawn. I had
that issue with the character classes.

A quick fix would be to put the line:

GetSprite().setTextureRect(...) and then fill in with a rectangle from the
sprite sheet.

On Friday, November 21, 2014, Joe Hause [email protected] wrote:

Still doesn't explain why the whole sheet is getting drawn at first though.


Reply to this email directly or view it on GitHub
#44 (comment).

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

My boundary settings were off. Sheet still getting drawn. Put that in the Bullet.cpp? You did that with bond and enemy?

from cs420-project.

Jagabel avatar Jagabel commented on August 16, 2024

Yeah sorry forgot to add that. Put that into the constructor...I added it
to Actor's constructor to fix the issue for bond/enemy

On Friday, November 21, 2014, Joe Hause [email protected] wrote:

My boundary settings were off. Sheet still getting drawn. Put that in the
Bullet.cpp? You did that with bond and enemy?


Reply to this email directly or view it on GitHub
#44 (comment).

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

Awesome, thanks dude

-Joseph Hause


Sent from my Android Device
On Nov 21, 2014 12:32 PM, "Jagabel" [email protected] wrote:

Yeah sorry forgot to add that. Put that into the constructor...I added it
to Actor's constructor to fix the issue for bond/enemy

On Friday, November 21, 2014, Joe Hause [email protected] wrote:

My boundary settings were off. Sheet still getting drawn. Put that in
the
Bullet.cpp? You did that with bond and enemy?


Reply to this email directly or view it on GitHub
#44 (comment).


Reply to this email directly or view it on GitHub
#44 (comment).

from cs420-project.

jhawz avatar jhawz commented on August 16, 2024

This has been resolved thanks to @Jagabel Bond sometimes slides on the right combination of key presses and the shooting animation stops after 2 frames or so.

from cs420-project.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.