Permalink
Browse files

Smore shite works

  • Loading branch information...
Raw-Bert committed Mar 29, 2018
1 parent 8e61c5a commit 3e83b796411c26a7c9965798741e427c44042e23
@@ -5,7 +5,7 @@ Projectile::Projectile(Scene * scene, bool heavy, int bitMask, int index)
proj[this->heavy = heavy]->setPhysicsBody(PhysicsBody::createCircle(0));
getBody()->setGravityEnable(false);
getBody()->setName("Projectile");
//getBody()->setName("Projectile");
getBody()->setTag(this->index = index);
getBody()->setCollisionBitmask(this->bitMask = bitMask);
getBody()->setContactTestBitmask(true);
@@ -15,10 +15,12 @@ Projectile::Projectile(Scene * scene, bool heavy, int bitMask, int index)
this->scene = scene;
if(!heavy)
{
getBody()->setName("LightProj");
runAction(act = Sequence::create(DelayTime::create(3), CallFunc::create(this,
callfunc_selector(Projectile::removeProjectial)), 0));
} else
{
getBody()->setName("HeavyProj");
runAction(act = Sequence::create(DelayTime::create(1), CallFunc::create(this,
callfunc_selector(Projectile::removeProjectial)), 0));
}
@@ -45,15 +47,17 @@ void Projectile::setSize(float scale)
if(!heavy)
{
getBody()->setName("LightProj");
getBody()->addShape(PhysicsShapeCircle::create((proj[heavy]->getContentSize()).width / 2));
} else
{
getBody()->setName("HeavyProj");
getBody()->addShape(PhysicsShapeCircle::create((proj[heavy]->getContentSize()).width / 8));
getBody()->setPositionOffset(Vec2(proj[heavy]->getContentSize().width * scale * .25, 0));
}
getBody()->setName("Projectile");
getBody()->setTag(index);
getBody()->setTag(index);
getBody()->setCollisionBitmask(bitMask);
getBody()->setContactTestBitmask(true);
}
@@ -13,6 +13,7 @@ Sheep::Sheep(Scene *ActiveScene, int bitMask)
auto size = getSprite()->getContentSize();
getSprite()->setPhysicsBody(PhysicsBody::createBox(size));
getBody()->setTag(5);
getBody()->setName("Sheep");
getBody()->setCollisionBitmask(bitMask);
getBody()->setContactTestBitmask(true);
getBody()->setDynamic(true);
@@ -57,7 +58,7 @@ bool Sheep::onDeath()
if (sheep1 == true)
{
setHP(200);
setPosition(200, 300, 0);
setPosition(400, 350, 0);
sheep1 = false;
}
else if (sheep1 == false && sheep2 == true)
@@ -538,19 +538,21 @@ void TutorialScene::update(float dt)
scrolls[5]->setZOrder(-2);
scrolls[6]->setZOrder(2);
//sheep->setZOrder(-2);
theRealDT = 0;
sheep->sheep2 = true;
}
else if (scrolls[6]->getZOrder() == 2 && theRealDT >= 22)
else if (scrolls[6]->getZOrder() == 2 && theRealDT >= 3)
{
scrolls[6]->setZOrder(-2);
scrolls[7]->setZOrder(2);
//sheep->setZOrder(1);
}
else if (scrolls[7]->getZOrder() == 2 && theRealDT >= 25 && sheep->sheep1 == false)
else if (scrolls[7]->getZOrder() == 2 && theRealDT >= 6 && sheep->sheep2 == false)
{
scrolls[7]->setZOrder(-2);
scrolls[8]->setZOrder(2);
}
else if (scrolls[8]->getZOrder() == 2 && theRealDT >= 28)
else if (scrolls[8]->getZOrder() == 2 && theRealDT >= 9)
{
scrolls[8]->setZOrder(-2);
scrolls[9]->setZOrder(2);
@@ -32,7 +32,7 @@ class TutorialScene : public cocos2d::Scene
//cocos2d::Sprite * sprite,*BG = cocos2d::Sprite::create("Assets/test level.png");
//cocos2d::Sprite3D *s3d = cocos2d::Sprite3D::create("Assets/test 3d model.c3b");
float movex, movey, vely;
cocos2d::Director *director;
private:
@@ -48,20 +48,50 @@ class TutorialScene : public cocos2d::Scene
players[0];
//printf("Tag1 = %d\nTag2 = %d\n\n", bodyA->getTag(), bodyB->getTag());
//OutputDebugStringA("Colision dicision\n");
if((bodyA->getName() == "Projectile"))
if ((bodyA->getName() == "LightProj") || (bodyA->getName() == "HeavyProj"))
{
bodyB->getOwner()->setPosition(bodyB->getPosition().x, bodyB->getPosition().y);
if(bodyA->getOwner() != nullptr)
//bodyB->getOwner()->setPosition(bodyB->getPosition().x, bodyB->getPosition().y);
if (bodyA->getOwner() != nullptr)
{
if(bodyB->getName() != "Platform")
bodyB->setVelocity(bodyB->getVelocity() + ((bodyB->getPosition() - bodyA->getPosition()).getNormalized() * 200));
for(int a = 0; a < 4; a++)
if(bodyB->getOwner()->getParent() == players[a])
players[a]->setInterupt(2);
bodyA->getOwner()->removeFromParent();
if (bodyB->getName() == "Sheep")
{
bodyA->getOwner()->removeFromParent();
sheep->setHP(sheep->getHP() -10);
}
else
{
if (bodyB->getName() != "Platform")
bodyB->setVelocity(bodyB->getVelocity() + ((bodyB->getPosition() - bodyA->getPosition()).getNormalized() * 200));
for (int a = 0; a < 4; a++)
if (bodyB->getOwner()->getParent() == players[a])
players[a]->setInterupt(2);
bodyA->getOwner()->removeFromParent();
}
}
}
}
//if ((bodyB->getName() == "LightProj") || (bodyB->getName() == "HeavyProj"))
//{
// bodyA->getOwner()->setPosition(bodyA->getPosition().x, bodyA->getPosition().y);
// if (bodyB->getOwner() != nullptr)
// {
// if (bodyA->getName() == "Sheep")
// {
// bodyB->getOwner()->removeFromParent();
// sheep->getHP() - 10;
// }
// else
// {
// if (bodyA->getName() != "Platform")
// bodyA->setVelocity(bodyA->getVelocity() + ((bodyA->getPosition() - bodyB->getPosition()).getNormalized() * 200));
// for (int a = 0; a < 4; a++)
// if (bodyA->getOwner()->getParent() == players[a])
// players[a]->setInterupt(2);
// bodyB->getOwner()->removeFromParent();
// }
// }
//
//}
return true;
}
@@ -77,18 +107,22 @@ class TutorialScene : public cocos2d::Scene
OutputDebugStringA((bodyA->getName() + " == " + bodyB->getName() + "\n").c_str());
OutputDebugStringA((to_string(bodyA->getTag()) + " == " + to_string(bodyB->getTag()) + "\n").c_str());
if((bodyA->getName() == "Projectile" || bodyB->getName() == "Projectile") && (bodyA->getTag() != bodyB->getTag()))
if ((bodyA->getName() == "HeavyProj" || bodyB->getName() == "HeavyProj" ||
bodyA->getName() == "LightProj" || bodyB->getName() == "LightProj") && (bodyA->getTag() != bodyB->getTag()))
{
OutputDebugStringA("Proj hit\n");
return true;
} else if((bodyA->getName() == "Projectile" || bodyB->getName() == "Projectile") && (bodyA->getTag() == bodyB->getTag()))
}
else if ((bodyA->getName() == "HeavyProj" || bodyB->getName() == "HeavyProj" ||
bodyA->getName() == "LightProj" || bodyB->getName() == "LightProj") && (bodyA->getTag() == bodyB->getTag()))
{
return false;
}
OutputDebugStringA((to_string(bodyA->getTag()) + " == " + to_string(bodyB->getTag()) + "\n").c_str());
if(bodyA->getName() == bodyB->getName())
if (bodyA->getName() == bodyB->getName())
return false;
return true;
};
@@ -97,9 +131,9 @@ class TutorialScene : public cocos2d::Scene
void contact();
AudioPlayer * audio = new AudioPlayer;
Player* players[4] = {new Player(this,1,0),new Player(this,1,1),new Player(this,1,2),new Player(this,1,3)};
Player* players[4] = { new Player(this,1,0),new Player(this,1,1),new Player(this,1,2),new Player(this,1,3) };
Sheep* sheep = new Sheep(this, 1);
//Put variables and sprites and stuff here
//Sprites for background and Pause Menu0
cocos2d::Sprite* background = cocos2d::Sprite::create("Assets/Background.png");
@@ -127,7 +161,7 @@ class TutorialScene : public cocos2d::Scene
cocos2d::Sprite* scroll2;
cocos2d::Sprite* scroll3;
cocos2d::Sprite* scroll4;
cocos2d::Sprite* scroll5;
cocos2d::Sprite* scroll5;
cocos2d::Sprite* scroll6;
cocos2d::Sprite* scroll7;
cocos2d::Sprite* scroll8;

0 comments on commit 3e83b79

Please sign in to comment.