Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - moonbeamer2234

Pages: [1]
1
Graphics / How can i move a group of rectangles at the same time?
« on: August 09, 2012, 03:44:30 am »
I have a Block in the shape of a T that looks like this
topleft.setPosition(middletop.getPosition().x-10, middletop.getPosition().y);
topleft.setFillColor(sf::Color::Red);
righttop.setPosition(middletop.getPosition().x+10, middletop.getPosition().y);
righttop.setFillColor(sf::Color::Blue);
bottom1.setPosition(middletop.getPosition().x, middletop.getPosition().y+10);
bottom1.setFillColor(sf::Color::Cyan);
bottom2.setPosition(bottom1.getPosition().x, bottom1.getPosition().y+10);
bottom2.setFillColor(sf::Color::Green);
middleblock is stationary and the other rectangles are build around it at the top of the page.
I want the all 5 rectangles to fall at the same time so i tried using a non void prototype and i think i might be on the right track but maybe im missing something that i cant figure out.
sf::RectangleShape tblock (sf::RectangleShape topleft, sf::RectangleShape middletop, sf::RectangleShape righttop,sf::RectangleShape bottom1, sf::RectangleShape bottom2)
,,
,,
,,
//Than for intitialising i did this
sf::RectangleShape tblock (sf::RectangleShape topleft, sf::RectangleShape middletop, sf::RectangleShape righttop,sf::RectangleShape bottom1, sf::RectangleShape bottom2).move(0, 1);
 
But nothing happened! Im so stumped maybe im just really overcomplicating everything. I tend to do that sometimes.  ;D Please help :(

2
I still cant get that code to work. I dont want the rectangle to be drawn and continue to be drawn while the key is held. I just want it to appear once and disapear even if the key is held

3
Graphics / Re: How can i transform my drawing into a 3d model?
« on: July 27, 2012, 05:40:05 pm »
Maybe this is out of my league(considering they probably have 30k worth of programs for this kind of thing) but im interested in creating models like square enix and pixar does. Kinda high def if you get what im saying.(FF, Kingdom Hearts, ect.) So for something like that do you think i should go with OpenGL?

4
Graphics / How can i transform my drawing into a 3d model?
« on: July 27, 2012, 04:01:50 am »
I have an isometric drawing of my character.(Front, Back, Left, Right, Bottom, Top) and its all shaded ect. Im not really sure where to go from here to turn it into a 3d character...Im thinking im gonna have to learn OpenGL but im not sure if theres a way to do this with sfml, or if im supposed to do this somehow within my drawing. Any help or redirection would be great ::)

5
Graphics / Re: Can you draw a shaped sprite?
« on: July 25, 2012, 04:22:33 pm »
When i use sprite collision wont the transparent area produce the collision area. For example if my character collides with an object. The character colliding wont actually produce and effect if it collides with said object. When the transparent box collides with said object wont the effect be produced? Or is there some way to work around this. Like this:
(I saw on some other guys post that you dont like this code format but i cant figure out the other one so im sorry, this is what i learned at cplusplus.org ;/)  :'(
Code: [Select]
void collision(sf::Sprite character, sf::RectangleShape &enemy)
{
    if(character.getPosition().x + character.getSize().x < enemy.getPosition().x ||
           character.getPosition().x > enemy.getPosition().x + enemy.getSize().x ||
           character.getPosition().y + character.getSize().y < enemy.getPosition().y ||
           character.getPosition().y > enemy.getPosition().y + enemy.getSize().y)}
{
}
else
{std::Cout << "Collision" << std::endl;}
Wont character.getposition().x = The x including the transparent area. And wont character.getposition().y = the y including the transparent area? So when the transparent area colides with enemy it will cout collision instead of couting collision when the sprite inside the transparent area collides with enemy?

6
Graphics / Re: Can you draw a shaped sprite?
« on: July 24, 2012, 05:28:52 pm »
because for collision that could be a problem since collision would be considered the transparent box, not the character itself

7
Graphics / Re: Can you draw a shaped sprite?
« on: July 24, 2012, 05:27:05 pm »
Thank you so much that definatly helped!!! But is there any way to do it within the code?

8
Graphics / Can you draw a shaped sprite?
« on: July 24, 2012, 04:42:20 pm »
Ive drawn a character for my game in gimp, but when i display sprite it brings up the character and the surrounding white box. Is there anyway to make the surounding white box transparent or to make the surrounding white box blend in with whatever enviroment its in? ;D

9


here is the part that im having problems with along with its class.

void collision(sf::RectangleShape snakebodym, sf::RectangleShape &enemy, sf::RectangleShape &stat, int cost)
//Collision with a stat drain(health, energy, ect)
{

    if(snakebodym.getPosition().x + snakebodym.getSize().x < enemy.getPosition().x ||
           snakebodym.getPosition().x > enemy.getPosition().x + enemy.getSize().x ||
           snakebodym.getPosition().y + snakebodym.getSize().y < enemy.getPosition().y ||
           snakebodym.getPosition().y > enemy.getPosition().y + enemy.getSize().y)
{

}
else
{


    stat.setSize(sf::Vector2f(stat.getSize().x-cost, stat.getSize().y-0));

    }}
//Class
[code=cpp]
[/code =none]
Here is the actual event
[code=none]
[/code=cpp]
if((event.type == sf::Event::KeyPressed) && (event.type != sf::Event::KeyReleased) && (event.key.code == sf::Keyboard::Z))
  {
    //Sword Draws according to direction
    if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right))
    {snakebody.setPosition(sf::Vector2f(snakebody.getPosition().x+175, snakebody.getPosition().y+0));
    sword.setPosition(sf::Vector2f(snakebody.getPosition().x-175, snakebody.getPosition().y+4));}
   else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left))
    {snakebody.setPosition(sf::Vector2f(snakebody.getPosition().x-175, snakebody.getPosition().y+0));
    sword.setPosition(sf::Vector2f(snakebody.getPosition().x+0, snakebody.getPosition().y+4));}
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Up))
    {snakebody.setPosition(sf::Vector2f(snakebody.getPosition().x+0, snakebody.getPosition().y-175));
    swordVerticle.setPosition(sf::Vector2f(snakebody.getPosition().x+4, snakebody.getPosition().y+0));}
    else if(sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
    {snakebody.setPosition(sf::Vector2f(snakebody.getPosition().x+0, snakebody.getPosition().y+175));
    swordVerticle.setPosition(sf::Vector2f(snakebody.getPosition().x+4, snakebody.getPosition().y-175));
    }



  }
if(!sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
{
    sword.setPosition(0, 0);
swordVerticle.setPosition(0,0);
}
//Not sure what to call this. Its right after the game loop where window.display, ect are. I think its class initialization maybe?
collision(sword,enemy,weaponhealth, 10);
[code=cpp]
     collision(swordVerticle, enemy, weaponhealth, 10);


[quote author=eXpl0it3r link=topic=8628.msg58125#msg58125 date=1343093270]
You sir must come from outerspace, what exactly are you talking about there with energy drains and unstable stuff? ??? ;D
(Don't expect people to know what you're working on. ;))

If you want to something to happen only once when you press a key you could do this with a boolean variable, e.g.:
[code=cpp]bool action = false;
// ...
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Z) && !action)
{
   action = true;
   // Do your stuff
}
else if(!sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
{
   action = false;
}


If you want a rect to get drawn only when you press a key you could do this like:
bool action = false;
// ...
if(sf::Keyboard::isKeyPressed(sf::Keyboard::Z))
{
   action = true;
}
// ...
if(action)
{
   window.draw(rect);
   action = false;
}
it drains weaponhealth instead of just taking 10 away. I dont want sword and swordverticle to remain when the button is pressed. I just want them to be displayed once no matter if the key is held or pressed once. and i just want weaponhealth to be deducted 10(according the the class) only once, regardless if the button is held or pressed.

10
General / How can i create an effect only once when a button is held?
« on: July 24, 2012, 03:08:25 am »
I dont know how to do it :[ I dont want the effect to continue if the button is held. its for the magic bar decreasing each time the Z key is Pressed. It draws a rectangle when the space key is pressed but it remains when it is held, so instead of just detucting the energy required from activating the rectangle drawn, its drains it according the amount of time(im assuming in miliseconds at the drain rate). So the energy deduction is unstable. how can i say syntactically that i want the rectangle to be drawn for the same amount of time when the key is held or just pressed once? I want them both to do the same thing basically

Pages: [1]