Hazard respawn is also working now
Still need to emit particles on HazardHarm tho
This commit is contained in:
		
							
								
								
									
										4
									
								
								app.c
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								app.c
									
									
									
									
									
								
							@@ -81,6 +81,10 @@ App *app_NewApp() {
 | 
			
		||||
	misc_InstantiateTextbox(app, text3, "Press ; to dash.\nYou can only dash one time midair.", misc_TextboxUpright(70, 70), -180);
 | 
			
		||||
	entity_Commit(app->entity, text3);
 | 
			
		||||
 | 
			
		||||
	Entity *respawn1 = entity_Create(app->entity, "respawn1");
 | 
			
		||||
	misc_InstantiateHazardRespawn(app, respawn1, box2(300, 500, 400, 50), vec2(500, 550));
 | 
			
		||||
	entity_Commit(app->entity, respawn1);
 | 
			
		||||
 | 
			
		||||
	return app;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -51,6 +51,25 @@ void app_Render(App *app) {
 | 
			
		||||
					(int)round(box.lefttop.x + box.size.x),
 | 
			
		||||
					(int)round(box.lefttop.y + box.size.y));
 | 
			
		||||
			}
 | 
			
		||||
			if (e->misc->respawn) {
 | 
			
		||||
				setlinecolor(RGB(255, 0, 255));
 | 
			
		||||
				Box2 box;
 | 
			
		||||
				Vec2 pos;
 | 
			
		||||
				if (e->position) {
 | 
			
		||||
					box = camera_TransformBox2(app->camera, box2_Offset(e->misc->respawn->trigger_box, e->position->position));
 | 
			
		||||
					pos = camera_TransformVec2(app->camera, vec2_Add(e->misc->respawn->respawn_pos, e->position->position));
 | 
			
		||||
				} else {
 | 
			
		||||
					box = camera_TransformBox2(app->camera, e->misc->respawn->trigger_box);
 | 
			
		||||
					pos = camera_TransformVec2(app->camera, e->misc->respawn->respawn_pos);
 | 
			
		||||
				}
 | 
			
		||||
				rectangle(
 | 
			
		||||
					(int)round(box.lefttop.x),
 | 
			
		||||
					(int)round(box.lefttop.y),
 | 
			
		||||
					(int)round(box.lefttop.x + box.size.x),
 | 
			
		||||
					(int)round(box.lefttop.y + box.size.y));
 | 
			
		||||
				line((int)round(pos.x + 12), (int)round(pos.y), (int)round(pos.x - 12), (int)round(pos.y));
 | 
			
		||||
				line((int)round(pos.x), (int)round(pos.y + 12), (int)round(pos.x), (int)round(pos.y - 12));
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										15
									
								
								player.c
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								player.c
									
									
									
									
									
								
							@@ -151,7 +151,22 @@ void player_Advance(System_Player *sys, Duration deltaTime) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// Respawn if fallen out of the world
 | 
			
		||||
	if (p->super->position->position.y > 5000)
 | 
			
		||||
		player_HazardHarm(sys);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	// Check OnGround again
 | 
			
		||||
	if (dabs(sys->player->super->position->velocity.y) > EPS)
 | 
			
		||||
		sys->player->onGround = false;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
void player_HazardHarm(System_Player *sys) {
 | 
			
		||||
	if (!sys->player)
 | 
			
		||||
		return;
 | 
			
		||||
	sys->player->storedSpeedY              = 0;
 | 
			
		||||
	sys->player->super->position->velocity = vec2(0, 0);
 | 
			
		||||
	sys->player->super->position->position = sys->player->hazardRespawn;
 | 
			
		||||
	sys->player->super->position->position.y -= EPS; // Stay loose!
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										10
									
								
								player.h
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								player.h
									
									
									
									
									
								
							@@ -52,6 +52,16 @@ void player_DeleteEntity(System_Player *sys, uintptr_t id);
 | 
			
		||||
// Called on every frame.
 | 
			
		||||
void player_Advance(System_Player *sys, Duration deltaTime);
 | 
			
		||||
 | 
			
		||||
// Harm the player.
 | 
			
		||||
// The player is hit backwards, releasing a puff of smoke.
 | 
			
		||||
//
 | 
			
		||||
// To be implemented
 | 
			
		||||
// void player_Harm(System_Player *sys, Vec2 source);
 | 
			
		||||
 | 
			
		||||
// Hazard harm the player.
 | 
			
		||||
// The player is teleported to the hazard respawn point.
 | 
			
		||||
void player_HazardHarm(System_Player *sys);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user