Jump to content

  • Log In with Google      Sign In   
  • Create Account

#ActualSharkBaitHooHaHa

Posted 30 August 2013 - 06:23 PM

Hello everyone!

it's been a long while since I've posted. I'll keep this topic short and sweet.

I just finished C++ at school and decided to start a project. Main game mechanic revolves around growing plants and using them in combat(still have a few ideas on this floating around but that's for another post another day tongue.png ). I am in the early stages and have decided to represent the plants as rectangles and have them slowly increase their height to grow upwards.

I have created a Plant class that inherits from sf::RectangleShape. Plant has width, height, x, and y floats.When I create a new plant it will take a constructor Plant(float w, float h, float x, float y). It will then use setSize(sf::Vector2f(w,h)) for its size and then position itself using setPosition(x,y).

As it is, when I change the height of the plant using setSize(), the plant would grow downward. If I were to have the plant grow upward I would have to increase its height while also shifting it down using either setPosition() or move(). This doesn't really seem optimal but I can't really think of any better way of doing this.

Another concern is whether the variable growthRate of plants should be handled by a varying multiplier, or "tick". Perhaps better phrased, should I "grow" all the plants at the same time and they vary how much they grow( every 10 seconds plants grow a variable height y), or should I grow all plants a universal height and they vary how often they grow( every plant grows 10px but they each grow every t seconds). Any thoughts?

-Adrian

EDIT:

I was being silly and completely forgot how inheritance worked, solved it quickly, and removed that part. The part pertaining to the actual plant growth still remains though. Sorry! I was too quick to post tongue.png


#2SharkBaitHooHaHa

Posted 30 August 2013 - 06:09 PM

Hello everyone!

it's been a long while since I've posted. I'll keep this topic short and sweet.

I just finished C++ at school and decided to start a project. Main game mechanic revolves around growing plants and using them in combat(still have a few ideas on this floating around but that's for another post another day :P ). I am in the early stages and have decided to represent the plants as rectangles and have them slowly increase their height to grow upwards.

I have created a Plant class that inherits from sf::RectangleShape. Plant has width, height, x, and y floats.When I create a new plant it will take a constructor Plant(float w, float h, float x, float y). It will then use setSize(sf::Vector2f(w,h)) for its size and then position itself using setPosition(x,y).

As it is, when I change the height of the plant using setSize(), the plant would grow downward. If I were to have the plant grow upward I would have to increase its height while also shifting it down using either setPosition() or move(). This doesn't really seem optimal but I can't really think of any better way of doing this. Any thoughts?

-Adrian

EDIT:

I was being silly and completely forgot how inheritance worked, solved it quickly, and removed that part. The part pertaining to the actual plant growth still remains though. Sorry! I was too quick to post :P


#1SharkBaitHooHaHa

Posted 30 August 2013 - 05:56 PM

Hello everyone!

it's been a long while since I've posted. I'll keep this topic short and sweet.

I just finished C++ at school and decided to start a project. Main game mechanic revolves around growing plants and using them(still have a few ideas on this floating around). I am in the early stages and have decided to represent the plants as rectangles and have them slowly increase their height to grow upwards.

I have created a Plant class that inherits from sf::RectangleShape. Plant has width, height, x, and y floats.When I create a new plant it will take a constructor Plant(float w, float h, float x, float y). It will then pass this into RectangleShape constructor in the style RectangleShape plant(sf::Vector2f(w,h)) and then position itself using plant.setPosition(x,y) as the constructor for RectangeShape does not have a constructor including initial position.

My problem here is I can't seem to wrap my head around how to create my plant object using these steps. Like I said I am just fresh off my C++ class and now am trying to apply my skills, but this is my first time working with an external library and am a little unsure on the implementation of my methods I mentioned above.

Feedback would be great!

[EXTRA]
Also if you can I'd like your thoughts on this. As it is, when I change the height of the plant using setSize(), the plant would grow downward. If I were to have the plant grow upward I would have to increase its height while also shifting it down using either setPosition() or move(). This doesn't really seem optimal but I can't really think of any better way of doing this. Again this is just extra, I still need a functioning Plant class first :P

-Adrian


PARTNERS