• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
KittyPlaysViolin

[SFML 2.1] Growing Plants

3 posts in this topic

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

Edited by SharkBaitHooHaHa
0

Share this post


Link to post
Share on other sites

Might want to go with a tree building algorithm. An L-system fractal generator would work for something like this.

0

Share this post


Link to post
Share on other sites

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?


Growing plants can be simple or complex, it depends on if you just want them as decoration or if they have actual gameplay importance. Without gameplay importance, simple random growing is probably fine and there is little reason to get all that fancy. With gameplay importance, it depends on how far you want to go and what level of complexity is appropriate.

I once wrote a tree growth system which paid attention to the following:

1. Surrounding tree's, too much higher and it stunts the tree's growth due to lack of light.
2. Fitness. Too many tree's in close proximity and the strongest survives, the others die out.
3. Terrain, rocky- slow growth, dirt- decent growth, tilled fields- fast growth.
4. Water availability. Both rainfall and relative distance to sources.
5. Local terrain curvature, i.e. locations water will likely catch and sink into the ground.
6. All sorts of other things like pollution, high wind whatever other nonsense you might want to plug in.

It was pretty silly over detailed but that was important to the game concept since tree's were an important resource. For something that "looks" OK and might not be so important to game play, 1+2 and a simple concept of local steepness would likely give plenty of variation and interest to a growth system.
0

Share this post


Link to post
Share on other sites

Ah, thanks for the replies guys! Just giving a quick update and some clarification. I scrapped the idea of using the RectangleShape class and decided to inherit from Sprite, as that took care of a lot more stuff for me. Also, my trees and plants aren't going to be geometrical entities themselves. Instead they are going to be textures. When a plant grows to a certain point it will change out textures, and some plants will even get a bigger texture. For example my tree would go from being 8x8 to 8x16. At this point I believe if I pass a bigger texture to the sprite using setTexture it would automatically scale itself as Sprite does not have a setSize method like RectangleShape did.

kd7tck:
That sounds like something really cool to research but alas that falls outside of the scope of my current ability and project :P I am merely dealing with tree sprites and the such. But thanks anyway!

AllEightUp:
I like the rules you have set up there, I think though my system will only worry about the plant's current hydration,temperature(accounts for sunlight as well as climate), and something resembling overall health. As it stands my game is going to be sidescrolling and my character is going to plant plants in pots, water them, and defend until they grow, at which point he can use them as allies. Once they mature enough, he can transfer them out of the pot into the ground to defend a certain location or provide access to certain location. 

ex. Player starts out at their home, brings out a pot and plants a seed, waters it, and takes it outside for it to start growing. Monsters walking around can aggro at a certain distance and come towards you. You protect the plant and it matures to its second stage. This plant is a basic Rose Thorn and can fire thorns at enemies. You pick up your pot and walk forward, the Rose thorn automatically attacking enemies as they come into range. You scavenge whatever you need from the area and take care of your plant's needs. Your plant matures to stage three and you head back home to plant it outside your base. Your plant is now permanently there, unless you decide to move it with the trowel(small plants only, and this reverts them to stage 2). It becomes night time and you retreat inside your base. Tower defense stage  starts up and you must use the plants you have available to defend your fortification. If you made a Tree and added a Vine to it for example you could use it to easily scale between different levels of your fort to help your plants protect your home. After enough scavanges and seige defenses you are able to take some of your materials, one of your potted plants, and head to a new area, leaving behind your plants to reclaim the area for nature.

What do you think? :]
 

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0