i am trying to code my sprites to collect items which then display a score in the top left of the screen depending on which items they collect, each sprite has their own item and there is an item which deducts score. However i am at a loss as to how to do this. Help please, i am using Visual C++ with SDL

Recommended Answers

All 2 Replies

Create a hierarchy :

class Item{
 //...
 virtual int points()const; //returns how much points this item is worth
};
class Book{
 //...
 int points()const{ return 2; }
};
class Food{
 //...
 int points()const{ return 5; }
} ;
//...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.