3
-canSprint
+Slow
0
canJump
0
-Slow
-1
+canSprint
+0
// a prototype of the world class, necessary for some function prototypes
class World;
+/**
+ * The light structure, used to store light coordinates and color.
+ */
+
+class Light{
+public:
+ vec2 loc; /**< Light location */
+ Color color; /**< Light color */
+ float radius; /**< Light radius */
+
+ bool belongsTo;
+ Entity *following;
+
+ bool flame;
+ float fireFlicker;
+ vec2 fireLoc;
+ Light()
+ {
+ loc = vec2(0,0);
+ color = Color(1.0, 1.0, 1.0);
+ radius = 0;
+
+ belongsTo = false;
+ following = nullptr;
+
+ flame = false;
+ }
+
+ Light(vec2 l, float r, Color c)
+ {
+ loc = l;
+ color = c;
+ radius = r;
+
+ belongsTo = false;
+ following = nullptr;
+
+ flame = false;
+ }
+
+ void follow(Entity *f)
+ {
+ following = f;
+ belongsTo = true;
+ }
+
+ void makeFlame(void)
+ {
+ flame = true;
+ }
+
+ void createFromXML(XMLElement *e);
+};
+
/**
* The entity class.
* This class contains common functions and variables for all types of
// the entity's inventory
Inventory *inv;
+ // the entity's light
+ Light light;
+
// the entity's health
float health;
void saveToXML(void);
};
-/**
- * The light structure, used to store light coordinates and color.
- */
-
-class Light{
-public:
- vec2 loc; /**< Light location */
- Color color; /**< Light color */
- float radius; /**< Light radius */
-
- bool belongsTo;
- Entity *following;
-
- bool flame;
- float fireFlicker;
- vec2 fireLoc;
-
- Light(vec2 l, float r, Color c)
- {
- loc = l;
- color = c;
- radius = r;
-
- belongsTo = false;
- following = nullptr;
-
- flame = false;
- }
-
- void follow(Entity *f)
- {
- following = f;
- belongsTo = true;
- }
-
- void makeFlame(void)
- {
- flame = true;
- }
-
- void createFromXML(XMLElement *e);
-};
-
/**
* The particle class, handles a single particle.
*/
* drawing.
*/
class World {
+friend class ItemLight;
protected:
/**
else
e->takeHit(damage, 600);
- static GLuint sColor = Texture::genColor(Color(255,0,0));
- GLfloat t[] = {0.0, 0.0,
- 1.0, 1.0};
- GLfloat v[] = {hitbox.start.x, hitbox.start.y, 1.0,
- hitbox.end.x, hitbox.end.y, 1.0};
-
-
- glBindTexture(GL_TEXTURE_2D, sColor);
- glUseProgram(worldShader);
- glEnableVertexAttribArray(worldShader_attribute_coord);
- glEnableVertexAttribArray(worldShader_attribute_tex);
-
- glVertexAttribPointer(worldShader_attribute_coord, 3, GL_FLOAT, GL_FALSE, 0, v);
- glVertexAttribPointer(worldShader_attribute_tex, 2, GL_FLOAT, GL_FALSE, 0, t);
- glDrawArrays(GL_LINES, 0, 2);
-
- glDisableVertexAttribArray(worldShader_attribute_coord);
- glDisableVertexAttribArray(worldShader_attribute_tex);
- glUseProgram(0);
// add some blood
- // for(int r = 0; r < (rand()%5);r++)
- // currentWorld->addParticle(rand()%game::HLINE*3 + e->loc.x - .05f,e->loc.y + e->height*.5, game::HLINE,game::HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000);
+ //for(int r = 0; r < (rand()%5);r++)
+ //currentWorld->addParticle(rand()%game::HLINE*3 + e->loc.x - .05f,e->loc.y + e->height*.5, game::HLINE,game::HLINE, -(rand()%10)*.01,((rand()%4)*.001-.002), {(rand()%75+10)/100.0f,0,0}, 10000);
}
}
int ItemLight::useItem()
{
- std::cout << "fsdfsdf" << std::endl;
+ if (player->light.radius > 0)
+ player->light.radius = 0;
+ else
+ player->light.radius = 500;
return 0;
}
drawNiceBox(vec2 {x, y}, vec2 {x + SCREEN_WIDTH - HLINES(16), y - SCREEN_HEIGHT / 4}, -7.0);
rtext = typeOut(dialogBoxText);
- putString(x + game::HLINE, y - fontSize - game::HLINE, rtext);
+ putString(x + (2*game::HLINE), y - fontSize - game::HLINE, rtext);
for(i=0;i<dialogOptText.size();i++) {
setFontColor(255,255,255);
uint ls = light.size();
- GLfloat *lightCoords = new GLfloat[light.size() * 4];
- GLfloat *lightColors = new GLfloat[light.size() * 4];
-
+ GLfloat *lightCoords = new GLfloat[ls * 4];
+ GLfloat *lightColors = new GLfloat[ls * 4];
+
uint lpIndex = 0;
uint lcIndex = 0;
-
+
for (uint i = 0; i < ls; i++) {
auto &l = light[i];
if (l.belongsTo) {
void World::
addLight(vec2 loc, float radius, Color color)
{
- if (light.size() < 64)
+ if (light.size() < 128)
light.emplace_back(loc, radius, color);
}
</text>
<text id="1">
...
- <gotox>700</gotox>
+ <gotox>700</gotox>
<set id="Slow" value="0"/>
</text>
</Dialog>
<Dialog name="Guy">
<text id="0" nextid="1">
- <gotox>-600</gotox>
+ Hello there! My name is Ralph.
+ <gotox>300</gotox>
</text>
- <text id="1">
- ...
- <gotox>1000</gotox>
- <set id="Slow" value="0"/>
- <set id="canSprint" value="1"/>
+ <text id="1" nextid="2" call="Johnny" callid="0" pause="true">
+ You should go talk to my friend Johnny. He's a pretty chill dude.
+ </text>
+ <text id="2">
+ Niice.
+ <quest check="Your First Quest" fail="3"/></text>
+ <text id="3">
+ Go check out Johnny. He's cool.
+ </text>
+</Dialog>
+
+<Dialog name="Johnny">
+ <text id="0" nextid="1" pause="true">
+ Sup bro! Have a quest. To complete it, just go talk to Ralph again.
+ <quest assign="Your First Quest">
+ Dank MayMay,2
+ Wood Sword,1
+ </quest>
</text>
+ <text id="1" nextid="1" pause="true">
+ Broooooooooooooo...
+ </text>
+</Dialog>
+
+<Dialog name="Big Dave">
+ <text id="0" stop="true">
+ Hey friend! It's dangerous out there, here take these!
+ Wait, promise you'll stop by my stand in the local market!
+ <give id="Wood Sword" count="1"/> <give id="Hunters Bow" count="1"/> <give id="Crude Arrow" count="110"/> <give id="Fried Chicken" count="1"/> <give id="Mossy Torch" count="1"/></text>
</Dialog>
<Dialog name="Bob">
<text id="0" nextid="1" pause="true">
- Hey. Have a Dank MayMay :)
- <give id="Dank MayMay" count="1"/></text>
+ Hey. Have a Dank MayMay :)
+ <give id="Dank MayMay" count="1"/></text>
<text id="1" nextid="2">
What? You want another Dank MayMay?
</text>
<text id="2" nextid="3" pause="true">
K.
- <give id="Dank MayMay" count="1"/></text>
+ <give id="Dank MayMay" count="1"/></text>
<text id="3" nextid="4">
Well... I'm out of Dank MayMays.
</text>
<text id="4">
Have a sword though.
- <give id="Wood Sword" count="1"/></text>
+ <give id="Wood Sword" count="1"/></text>
</Dialog>