示例#1
0
文件: seg004.c 项目: kees/SDLPoP
// seg004:0448
void __pascal far bumped(sbyte delta_x,sbyte push_direction) {
	// frame 177: spiked
	if (Char.alive < 0 && Char.frame != 177) {
		Char.x += delta_x;
		if (push_direction < dir_0_right) {
			// pushing left
			if (curr_tile2 == tiles_20_wall) {
				get_tile(curr_room, --tile_col, tile_row);
			}
		} else {
			// pushing right
			if (curr_tile2 == tiles_12_doortop ||
				curr_tile2 == tiles_7_doortop_with_floor ||
				curr_tile2 == tiles_20_wall
			) {
				++tile_col;
				if (curr_room == 0 && tile_col == 10) {
					curr_room = Char.room;
					tile_col = 0;
				}
				get_tile(curr_room, tile_col, tile_row);
			}
		}
		if (tile_is_floor(curr_tile2)) {
			bumped_floor(push_direction);
		} else {
			bumped_fall();
		}
	}
}
示例#2
0
 bool on_ground()
 {
   return
     vel_y == 0 &&
     (get_tile(x + 16, y + 16) != ' ' ||
      get_tile(x - 16, y + 16) != ' ');
 }
示例#3
0
文件: player.c 项目: codl/ponyrl
void move_player(enum direction direction){
    int x, y, ele;
    int xx, yy;
    struct square *from, *to;
    struct tile *tilefrom, *tileto;

    x = xx = player.x;
    y = yy = player.y;
    ele = player.ele;
    switch(direction){
        case(NW):
            xx = x - 1;
        case(N):
            yy = y - 1;
            break;
        case(SW):
            yy = y + 1;
        case(W):
            xx = x - 1;
            break;
        case(SE):
            xx = x + 1;
        case(S):
            yy = y + 1;
            break;
        case(NE):
            yy = y - 1;
        case(E):
            xx = x + 1;
            break;
    }
    tilefrom = get_tile(pos_div(x, TILESIZE), pos_div(y, TILESIZE), 0);
    if(pos_div(x, TILESIZE) == pos_div(xx, TILESIZE) && pos_div(y, TILESIZE) == pos_div(yy, TILESIZE))
        tileto = tilefrom;
    else
        tileto = get_tile(pos_div(xx, TILESIZE), pos_div(yy, TILESIZE), 0);
    from = tilefrom->type == Array? SQUARE(tilefrom->tile.sq, pos_mod(x, TILESIZE), pos_mod(y, TILESIZE)) : tilefrom->tile.fill;
    to = tileto->type == Array? SQUARE(tileto->tile.sq, pos_mod(xx, TILESIZE), pos_mod(yy, TILESIZE)) : tileto->tile.fill;
    // TODO handle elevation / going to adjacent layers
    if(to->c){
        // TODO FIGHT or do other things I guess
        hit(to->c,&player);
    }
    else {
        // try moving
        switch(to->terrain){
            case(TERRAIN_ROCK_WALL):
                putmsg("You bump into a wall.");
                break;
            default:
                from->c = 0;
                player.x = xx;
                player.y = yy;
                to->c = &player;
                draw_map(xx, yy, ele);
        }
    }
}
void
SectorParser::fix_old_tiles()
{
  for(const auto& solids : m_sector.solid_tilemaps) {
    for(size_t x=0; x < solids->get_width(); ++x) {
      for(size_t y=0; y < solids->get_height(); ++y) {
        const auto& tile = solids->get_tile(x, y);

        if (tile->get_object_name().length() > 0) {
          Vector pos = solids->get_tile_position(x, y);
          try {
            GameObjectPtr object = ObjectFactory::instance().create(tile->get_object_name(), pos, AUTO, tile->get_object_data());
            m_sector.add_object(object);
            solids->change(x, y, 0);
          } catch(std::exception& e) {
            log_warning << e.what() << "" << std::endl;
          }
        }

      }
    }
  }

  // add lights for special tiles
  for(const auto& obj : m_sector.gameobjects) {
    auto tm = dynamic_cast<TileMap*>(obj.get());
    if (!tm) continue;
    for(size_t x=0; x < tm->get_width(); ++x) {
      for(size_t y=0; y < tm->get_height(); ++y) {
        const auto& tile = tm->get_tile(x, y);
        uint32_t attributes = tile->getAttributes();
        Vector pos = tm->get_tile_position(x, y);
        Vector center = pos + Vector(16, 16);

        if (attributes & Tile::FIRE) {
          if (attributes & Tile::HURTS) {
            // lava or lavaflow
            // space lights a bit
            if ((tm->get_tile(x-1, y)->getAttributes() != attributes || x%3 == 0)
                 && (tm->get_tile(x, y-1)->getAttributes() != attributes || y%3 == 0)) {
              float pseudo_rnd = (float)((int)pos.x % 10) / 10;
              m_sector.add_object(std::make_shared<PulsingLight>(center, 1.0f + pseudo_rnd, 0.8f, 1.0f, Color(1.0f, 0.3f, 0.0f, 1.0f)));
            }
          } else {
            // torch
            float pseudo_rnd = (float)((int)pos.x % 10) / 10;
            m_sector.add_object(std::make_shared<PulsingLight>(center, 1.0f + pseudo_rnd, 0.9f, 1.0f, Color(1.0f, 1.0f, 0.6f, 1.0f)));
          }
        }

      }
    }
  }
}
示例#5
0
static void linear_shortcut (GeglBufferIterator *iter)
{
  GeglBufferIteratorPriv *priv = iter->priv;
  SubIterState *sub0 = &priv->sub_iter[0];
  int index;
  int re_use_first[16] = {0,};

  for (index = priv->num_buffers-1; index >=0 ; index--)
  {
    SubIterState *sub = &priv->sub_iter[index];

    sub->real_roi    = sub0->full_rect;
    iter->roi[index] = sub0->full_rect;
    iter->length = iter->roi[0].width * iter->roi[0].height;

    if (priv->sub_iter[0].buffer == sub->buffer && index != 0)
    {
      if (sub->format == priv->sub_iter[0].format)
        re_use_first[index] = 1;
    }

    if (!re_use_first[index])
    {
      gegl_buffer_lock (sub->buffer);
      if (index == 0)
        get_tile (iter, index);
      else
      {
        if (sub->buffer->tile_width == sub->buffer->extent.width 
            && sub->buffer->tile_height == sub->buffer->extent.height
            && sub->buffer->extent.x == iter->roi[index].x
            && sub->buffer->extent.y == iter->roi[index].y)
        {
          get_tile (iter, index);
        }
        else
          get_indirect (iter, index);
      }
    }
  }
  for (index = 1; index < priv->num_buffers; index++)
  {
    if (re_use_first[index])
    {
      g_print ("!\n");
      iter->data[index] = iter->data[0];
    }
  }

  priv->state = GeglIteratorState_Invalid; /* quit on next iterator_next */
}
// -----------------------------------------------------------------------
// reset river tiles
// -----------------------------------------------------------------------
void t_battlefield_terrain_map::set_river_height()
{
	t_map_point_2d point;
	t_map_point_2d offset;
	t_map_point_2d new_point;
	int			   size = get_size();
	int			   row_end;
	t_terrain_type terrain;

	for (point.row = 0; point.row < size; point.row++)
	{
		point.column = get_tile_row_start( point.row );
		row_end = get_tile_row_end( point.row );
		for (; point.column < row_end; point.column++)
		{
			terrain = get_tile( point ).get_terrain();
			if (terrain != k_terrain_water_river && terrain != k_terrain_ice_river)
				continue;
			for (offset.row = 0; offset.row <= 1; offset.row++)
			{
				for (offset.column = 0; offset.column <= 1; offset.column++)
				{
					new_point = point + offset;
					if (is_valid( new_point ))
						reset_height( new_point, k_battlefield_base_height );
				}
			}
		}	
	}
}
示例#7
0
void get_tile_quality(unsigned int i, float q[2])
{
    struct tile *T = get_tile(i);

    q[0] = T->quality[0];
    q[1] = T->quality[1];
}
示例#8
0
文件: seg002.c 项目: mfn/SDLPoP
// seg002:09F8
void __pascal far guard_follows_kid_down() {
	// This is called from autocontrol_guard_active, so char=Guard, Opp=Kid
	word opp_action;
	opp_action = Opp.action;
	if (opp_action == actions_2_hang_climb || opp_action == actions_6_hang_straight) {
		return;
	}
	if (// there is wall in front of Guard
		wall_type(get_tile_infrontof_char()) != 0 ||
		(! tile_is_floor(curr_tile2) && (
			(get_tile(curr_room, tile_col, ++tile_row) == tiles_2_spike ||
			// Guard would fall on loose floor
			curr_tile2 == tiles_11_loose ||
			// ... or wall (?)
			wall_type(curr_tile2) != 0 ||
			// ... or into a chasm
			! tile_is_floor(curr_tile2)) ||
			// ... or Kid is not below
			Char.curr_row + 1 != Opp.curr_row
		))
	) {
		// don't follow
		droppedout = 0;
		move_2_backward();
	} else {
		// follow
		move_1_forward();
	}
}
示例#9
0
void render(GameState *game)
{
    int h, w;
    int num_captured = 0;

    clear();
    getmaxyx(stdscr, h, w);

    for (int y = 0; y < h; y++)
        for (int x = 0; x < w; x++) {
            cchar_t pic;
            char_for_tile(get_tile(game, x, y), &pic);
            mvadd_wch(y, x, &pic);
        }

    for (size_t i = 0; i < game->num_letters; i++)
        if (game->letters[i].captured)
            mvaddch(SIZEY + 1, num_captured++, game->letters[i].val);
        else
            mvaddch(
                    game->letters[i].pos.y,
                    game->letters[i].pos.x,
                    game->letters[i].val
                   );

    mvaddch(game->player.pos.y, game->player.pos.x, '@');

    refresh();
}
示例#10
0
文件: seg002.c 项目: mfn/SDLPoP
// seg002:0680
void __pascal far sword_disappears() {
	// Special event: sword disappears
	if (current_level == 12 && Char.room == 18) {
		get_tile(15, 1, 0);
		curr_room_tiles[curr_tilepos] = tiles_1_floor;
	}
}
示例#11
0
文件: seg004.c 项目: kees/SDLPoP
// seg004:0989
void __pascal far check_chomped_guard() {
	get_tile_at_char();
	if ( ! check_chomped_here()) {
		get_tile(curr_room, ++tile_col, tile_row);
		check_chomped_here();
	}
}
示例#12
0
文件: rexspeeder.cpp 项目: Dka8/rltk
//===========================================================================================================//
//    Loading an xp file                                                                                     //
//===========================================================================================================//
	rex_sprite::rex_sprite(std::string const & filename)
	{
		typedef void* vp;
		//Number of bytes in a tile. Not equal to sizeof(RexTile) due to padding.
		const int tileLen = 10; 

		gzFile gz;
		try {
			gz = s_gzopen(filename.c_str(), "rb");

			s_gzread(gz, (vp)&version, sizeof(version));
			s_gzread(gz, (vp)&num_layers, sizeof(num_layers));
			s_gzread(gz, (vp)&width, sizeof(width));
			s_gzread(gz, (vp)&height, sizeof(height));

			layers.resize(num_layers);

			for (int i = 0; i < num_layers; i++)
				layers[i] = rex_layer(width, height);

			for (int layer_index = 0; layer_index < num_layers; layer_index++) {
				for (int i = 0; i < width*height; ++i)
					s_gzread(gz, get_tile(layer_index, i), tileLen);

				//The layer and height information is repeated.
				//This is expected to read off the end after the last layer.
				s_gzread(gz, (vp)&width, sizeof(width));
				s_gzread(gz, (vp)&height, sizeof(height));
			}
		}
		catch (...) { throw; }

		gzclose(gz);
	}
示例#13
0
文件: rexspeeder.cpp 项目: Dka8/rltk
//===========================================================================================================//
//    Saving an xp file                                                                                      //
//===========================================================================================================//
	void rex_sprite::save(std::string const & filename)
	{
		typedef void* vp;
		//Number of bytes in a tile. Not equal to sizeof(RexTile) due to padding.
		const int tileLen = 10; 

		try {
			gzFile gz = s_gzopen(filename.c_str(), "wb");

			s_gzwrite(gz, (vp)&version, sizeof(version));
			s_gzwrite(gz, (vp)&num_layers, sizeof(num_layers));

			for (int layer = 0; layer < num_layers; ++layer) {
				s_gzwrite(gz, (vp)&width, sizeof(width));
				s_gzwrite(gz, (vp)&height, sizeof(height));

				for (int i = 0; i < width*height; ++i) 
					//Note: not "sizeof(RexTile)" because of padding.
					s_gzwrite(gz, (vp)get_tile(layer,i), tileLen);
				
			}

			gzflush(gz, Z_FULL_FLUSH);
			gzclose(gz);
		}
		catch (...) { throw; }
	}
示例#14
0
bool levelMap::can_step(int x, int y){
	if(get_tile(x, y) == 0x128  && Map[y][x].Occupied != true){
		return true;
	}else{
		return false;
	}
}
示例#15
0
文件: gc_grid.c 项目: xbuster17/minig
void grid_generate(void) {
    uint maxx = terrain_sprite->count_x;
    uint maxy = terrain_sprite->count_y;
    uint mult = terrain_sprite->pixs;

    // float half_texel = terrain_tex->x;

    float fmultx = (float)mult / (float)terrain_tex->x;
    float fmulty = (float)mult / (float)terrain_tex->y;

    grid_renew_data();
    uint i;


    uint iset = 0;
    for(i = 0; i < grid_size * 2 * 6;) {
        get_tile(iset++, &x, &y);

        grid_texc[i++] = (((x % maxx)   ) * fmultx);
        grid_texc[i++] = (((y % maxy) +1) * fmulty);
        grid_texc[i++] = (((x % maxx) +1) * fmultx);
        grid_texc[i++] = (((y % maxy) +1) * fmulty);
        grid_texc[i++] = (((x % maxx)   ) * fmultx);
        grid_texc[i++] = (((y % maxy)   ) * fmulty);
        grid_texc[i++] = (((x % maxx)   ) * fmultx);
        grid_texc[i++] = (((y % maxy)   ) * fmulty);
        grid_texc[i++] = (((x % maxx) +1) * fmultx);
        grid_texc[i++] = (((y % maxy) +1) * fmulty);
        grid_texc[i++] = (((x % maxx) +1) * fmultx);
        grid_texc[i++] = (((y % maxy)   ) * fmulty);
    }
    grid_update_texc_vbo();
}
示例#16
0
文件: seg004.c 项目: kees/SDLPoP
// seg004:08C3
void __pascal far check_guard_bumped() {
	short var_2;
	if (
		word_1F950 == 0 &&
		Char.action == actions_1_run_jump &&
		Char.alive < 0 &&
		Char.sword >= sword_2_drawn
	) {
		if (
			get_tile_at_char() == tiles_20_wall ||
			curr_tile2 == tiles_7_doortop_with_floor ||
			(curr_tile2 == tiles_4_gate && can_bump_into_gate()) ||
			(Char.direction >= dir_0_right && (
				get_tile(curr_room, --tile_col, tile_row) == tiles_7_doortop_with_floor ||
				(curr_tile2 == tiles_4_gate && can_bump_into_gate())
			))
		) {
			load_frame_to_obj();
			set_char_collision();
			if (is_obstacle()) {
				var_2 = dist_from_wall_behind(curr_tile2);
				if (var_2 < 0 && var_2 > -13) {
					Char.x = char_dx_forward(-var_2);
					seqtbl_offset_char(65); // pushed to wall with sword (Guard)
					play_seq();
					load_fram_det_col();
				}
			}
		}
	}
}
示例#17
0
void get_tile_o(unsigned int i, float o[3])
{
    struct tile *T = get_tile(i);

    o[0] = T->o[0];
    o[1] = T->o[1];
    o[2] = T->o[2];
}
示例#18
0
void get_tile_u(unsigned int i, float u[3])
{
    struct tile *T = get_tile(i);

    u[0] = T->u[0];
    u[1] = T->u[1];
    u[2] = T->u[2];
}
示例#19
0
void Map::highlight(TileCoords tc) {
	Tile *t = get_tile(tc);
	if(t == NULL) {
		Log::Infof("Highlighted nonexistent tile");
	} else {
		t->highlighted = true;
	}
}
示例#20
0
void get_tile_r(unsigned int i, float r[3])
{
    struct tile *T = get_tile(i);

    r[0] = T->r[0];
    r[1] = T->r[1];
    r[2] = T->r[2];
}
示例#21
0
文件: seg004.c 项目: kees/SDLPoP
// seg004:0226
int __pascal far get_left_wall_xpos(int room,int column,int row) {
	short type;
	type = wall_type(get_tile(room, column, row));
	if (type) {
		return wall_dist_from_left[type] + coll_tile_left_xpos;
	} else {
		return 0xFF;
	}
}
示例#22
0
文件: rexspeeder.cpp 项目: Dka8/rltk
//===========================================================================================================//
//    Utility Functions                                                                                      //
//===========================================================================================================//
	void rex_sprite::flatten() {
		if (num_layers == 1)
			return;

		//Paint the last layer onto the second-to-last
		for (int i = 0; i < width*height; ++i) {
			rltk::vchar* overlay = get_tile(num_layers - 1, i);
			if (!is_transparent(overlay)) {
				*get_tile(num_layers - 2, i) = *overlay;
			}
		}

		//Remove the last layer
		--num_layers;

		//Recurse
		flatten();
	}	
示例#23
0
文件: seg004.c 项目: kees/SDLPoP
// seg004:025F
int __pascal far get_right_wall_xpos(int room,int column,int row) {
	short type;
	type = wall_type(get_tile(room, column, row));
	if (type) {
		return coll_tile_left_xpos - wall_dist_from_right[type] + 13;
	} else {
		return 0;
	}
}
示例#24
0
文件: map.cpp 项目: ALEXLCC/pyland
bool Map::is_walkable(int x_pos, int y_pos) {
    if (special_layer_id != 0) {
        // Block only in the case where a tile is set on the special layer
        auto layer = ObjectManager::get_instance().get_object<Layer>(special_layer_id);
        if (layer->get_tile(x_pos, y_pos).second == 1) {
            return false;
        }
    }
    return true;
}
示例#25
0
glyph Worldmap::get_glyph(int x, int y)
{
/*
  if (x < 0 || x >= WORLDMAP_SIZE || y < 0 || y >= WORLDMAP_SIZE) {
    return glyph();
  }
*/
  Worldmap_tile* tile = get_tile(x, y);
  glyph ret = tile->top_glyph();
  if (tile->terrain->has_flag(WTF_LINE_DRAWING)) {
    bool north = (get_tile(x, y - 1)->terrain->has_flag(WTF_LINE_DRAWING));
    bool  east = (get_tile(x + 1, y)->terrain->has_flag(WTF_LINE_DRAWING));
    bool south = (get_tile(x, y + 1)->terrain->has_flag(WTF_LINE_DRAWING));
    bool  west = (get_tile(x - 1, y)->terrain->has_flag(WTF_LINE_DRAWING));
    ret.make_line_drawing(north, east, south, west);
  }

  return ret;
}
示例#26
0
void Map::draw(Screen *s) {
	TileCoords tc;
	for(int i = 0; i < h; i++) {
		for(int j = 0; j < w; j++) {
			tc.x = j;
			tc.y = i;
			tile_drawer->draw_tile(s, get_tile(tc), (int)(PlayState::BASE_TILE_SIZE)*j, (int)(PlayState::BASE_TILE_SIZE)*i);
		}
	}
}
示例#27
0
int					/* O - -1 on error, 0 on success */
_cupsImagePutRow(
    cups_image_t    *img,		/* I - Image */
    int             x,			/* I - Start column */
    int             y,			/* I - Row */
    int             width,		/* I - Row width */
    const cups_ib_t *pixels)		/* I - Pixel data */
{
  int		bpp,			/* Bytes per pixel */
		count;			/* Number of pixels to put */
  int		tilex,			/* Column within tile */
		tiley;			/* Row within tile */
  cups_ib_t	*ib;			/* Pointer to pixels in tile */


  if (img == NULL || y < 0 || y >= img->ysize || x >= img->xsize)
    return (-1);

  if (x < 0)
  {
    width += x;
    x = 0;
  }

  if ((x + width) > img->xsize)
    width = img->xsize - x;

  if (width < 1)
    return (-1);

  bpp   = img->colorspace < 0 ? -img->colorspace : img->colorspace;
  tilex = x / CUPS_TILE_SIZE;
  tiley = y / CUPS_TILE_SIZE;

  while (width > 0)
  {
    ib = get_tile(img, x, y);

    if (ib == NULL)
      return (-1);

    img->tiles[tiley][tilex].dirty = 1;

    count = CUPS_TILE_SIZE - (x & (CUPS_TILE_SIZE - 1));
    if (count > width)
      count = width;
    memcpy(ib, pixels, count * bpp);
    pixels += count * bpp;
    x      += count;
    width  -= count;
    tilex  ++;
  }

  return (0);
}
示例#28
0
文件: map.cpp 项目: ALEXLCC/pyland
int Map::get_tile_type(int x, int y) {
    if (special_layer_id != 0) {
        auto layer = ObjectManager::get_instance().get_object<Layer>(special_layer_id);
        if ((layer->get_width_tiles() <= x) || (layer->get_height_tiles() <= y) || (x < 0) || (y < 0)) {
            return 0; //The edge of the map is normal
        } else {
            return layer->get_tile(x, y).second;
        }
    }
    return -1;
}
示例#29
0
文件: seg004.c 项目: kees/SDLPoP
// seg004:0343
int __pascal far is_obstacle_at_col(int tile_col) {
	short tile_row;
	tile_row = Char.curr_row;
	if (tile_row < 0) {
		tile_row += 3;
	}
	if (tile_row >= 3) {
		tile_row -= 3;
	}
	get_tile(curr_row_coll_room[tile_col], tile_col, tile_row);
	return is_obstacle();
}
示例#30
0
文件: seg004.c 项目: kees/SDLPoP
// seg004:076B
void __pascal far check_chomped_kid() {
	short tile_col;
	short tile_row;
	tile_row = Char.curr_row;
	for (tile_col = 0; tile_col < 10; ++tile_col) {
		if (curr_row_coll_flags[tile_col] == 0xFF &&
			get_tile(curr_row_coll_room[tile_col], tile_col, tile_row) == tiles_18_chomper &&
			(curr_room_modif[curr_tilepos] & 0x7F) == 2 // closed chomper
		) {
			chomped();
		}
	}
}