Example #1
0
File: game.c Project: phoboz/edom
void update_screen(coord x, coord y)
{
  coord sx, sy, px, py;

  /* Find the current general section. */
  get_current_section_coordinates(d.px, d.py, &sx, &sy);

#ifdef UPDATE_PANEL_VIEW
  coord opsx, opsy;

  /* Memorize the old panel view. */
  opsx = d.psx;
  opsy = d.psy;
  
  /* Adjust the panel view. */
  while (sx < d.psx)
    d.psx--;
  while (d.psx + 4 < sx)
    d.psx++;
  while (sy < d.psy)
    d.psy--;
  while (d.psy + 1 < sy)
    d.psy++;

  /* Repaint the whole screen map if necessary. */
  if (opsx != d.psx || opsy != d.psy)
    paint_map();
#endif

  /* Make the immediate surroundings known. */
  for (px = x - 1; px <= x + 1; px++)
    for (py = y - 1; py <= y + 1; py++)
      know(px, py);

  /* Check whether the PC is in a room or not. */
  get_current_section(d.px, d.py, &sx, &sy);

  /* Make rooms known. */
  if (sx != -1 && sy != -1)
    know_section(sx, sy);

  move_dungeon();

  draw_dungeon();
  draw_monsters();
  draw_actor(&d.pa);

  draw_player_status();

  flip();
}
Example #2
0
void draw_world(world_data* world, ne::transform3f view) {

	ne::set_texture(assets.textures.tileset);

	for (auto& i : world->chunks) {
		if (!chunk_in_view(view, &i.second)) {
			continue;
		}
		render_tile_chunk(&i.second);
		draw_tile_chunk(&i.second);
	}

	for (auto& i : world->chunks) {
		if (!chunk_in_view(view, &i.second)) {
			continue;
		}
		draw_chests(&i.second.chests);
		draw_warps(&i.second.warps);
		draw_npcs(&i.second.npcs);
	}

	draw_monsters(&world->monsters);
	draw_player(&world->player);

	for (auto& i : world->attacks) {
		if (i.attack_type = ATTACK_NORMAL_ARROW) {
			ne::set_drawing_shape(0);
			ne::set_model_matrix(&i.area);
			ne::set_texture(assets.textures.weapons.arrow);
			ne::draw_vertices();
		}
	}

	if (ne::is_key_down(KEY_1)) {
		for (auto& i : world->monsters) {
			draw_entity_collision(&i);
		}
		for (auto& i : world->chunks) {
			if (!chunk_in_view(view, &i.second)) {
				continue;
			}
			for (auto& j : i.second.chests) {
				draw_entity_collision(&j);
			}
		}
		draw_entity_collision(&world->player);
	}
}