本文整理汇总了Java中org.jsfml.system.Vector2i类的典型用法代码示例。如果您正苦于以下问题:Java Vector2i类的具体用法?Java Vector2i怎么用?Java Vector2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2i类属于org.jsfml.system包,在下文中一共展示了Vector2i类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: ResourcesMap
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Constructs the map.
* @param size : the size of the resources map in tiles
*/
public ResourcesMap(Vector2i size) {
this.size = size;
// Instantiates the resources
this.resources = new ArrayList<List<ResourcesStack>>();
// Create a large enough two-dimensional array.
for(int i = 0 ; i < size.y ; ++i) {
ArrayList<ResourcesStack> row = new ArrayList<ResourcesStack>();
for(int j = 0 ; j < size.x ; ++j) {
row.add(new ResourcesStack());
}
this.resources.add(row);
}
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:22,代码来源:ResourcesMap.java
示例2: ZoneMap
import org.jsfml.system.Vector2i; //导入依赖的package包/类
public ZoneMap(int width, int height) {
this.size = new Vector2i(width, height);
// Instantiates the zones
this.zoneMap = new ArrayList<List<Zone>>();
// Create a large enough two-dimensional array.
for(int i = 0 ; i < size.y ; ++i) {
ArrayList<Zone> zone = new ArrayList<Zone>();
for(int j = 0 ; j < size.x ; ++j) {
zone.add(new Zone(j, i, Zone.ZoneClass.FREE));
}
this.zoneMap.add(zone);
}
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:18,代码来源:ZoneMap.java
示例3: checkLevelUp
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Check for level up a house;
* @param resources : the resources map
*/
public boolean checkLevelUp(ResourcesMap resources) {
int random = (int)(Math.random()*10);
boolean maxSatisfaction = true;
ResourcesStack rstack = new ResourcesStack();
for(int x = this.hitbox.left ; x < this.hitbox.left + this.hitbox.width ; ++x) {
for(int y = this.hitbox.top ; y < this.hitbox.top + this.hitbox.height ; ++y) {
rstack.add(resources.getResources(new Vector2i(x, y)));
}
}
for(Need need : this.needs) {
if(need.amount*need.fillFactor > rstack.get(need.type)) {
maxSatisfaction = false;
break;
}
}
if(maxSatisfaction && random == 6) {
if(this.levelUp())
return true;
else
return false;
}
return false;
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:30,代码来源:Building.java
示例4: countBuildingsInArea
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Counts the number of buildings in the given area.
*
* @param centerOfArea : the center of the area
* @param range : the radius of the area
* @param buildingList : the list of buildings to consider
* @return the number of buildings in the area
*/
public int countBuildingsInArea(Vector2i centerOfArea, int range, List<Building> buildingList) {
int inRange = 0;
for(Building building : buildingList) {
Vector2i buildingCenter = new Vector2i(building.getHitbox().left + building.getHitbox().width / 2,
building.getHitbox().top + building.getHitbox().height / 2);
int distance = (int)Distance.euclidean(buildingCenter, centerOfArea);
if(distance < range) {
inRange++;
}
}
return inRange;
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:24,代码来源:Sim.java
示例5: GameSpeedGui
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Constructor
* @param textures : texture of the pause
* @param x : position x of the pause
* @param y : position y of the pause
*/
public GameSpeedGui(TextureManager textures, FontManager fonts, int x, int y) {
this.position = new Vector2i(x, y);
setSpeedCoeff(GameSpeed.x1);
this.timer = Time.ZERO;
this.sprite = new Sprite();
this.sprite.setTexture(textures.get(TextureID.PAUSE));
this.sprite.setPosition(this.position.x , this.position.y);
this.pauseFlag = true;
this.text = new Text();
this.text.setFont(fonts.get(FontID.CAVIAR_DREAM));
this.text.setPosition(this.position.x - 10, this.position.y + 50);
this.text.setColor(Color.WHITE);
this.text.setCharacterSize(16);
this.text.setString("00 : 00");
this.temp = 0;
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:26,代码来源:GameSpeedGui.java
示例6: updateDirection
import org.jsfml.system.Vector2i; //导入依赖的package包/类
public void updateDirection(Vector2i pos, Vector2i sizeWindow) {
if(pos.x+pos.y>=sizeWindow.x){
if(sizeWindow.x-pos.x+pos.y>=sizeWindow.x){
this.setDirection(4);
}
else{
this.setDirection(2);
}
}
if(pos.x+pos.y<=sizeWindow.x) {
if (sizeWindow.x - pos.x + pos.y <= sizeWindow.x) {
this.setDirection(1);
}
else{
this.setDirection(3);
}
}
}
开发者ID:FuriousCatInteractive,项目名称:AlektoroZombie,代码行数:19,代码来源:Mob.java
示例7: updateDirection
import org.jsfml.system.Vector2i; //导入依赖的package包/类
public void updateDirection(Vector2i pos, Vector2i sizeWindow) {
if(pos.x+pos.y>=sizeWindow.x){
if(sizeWindow.x-pos.x+pos.y>=sizeWindow.x){
this.setDirection(1);
}
else{
this.setDirection(3);
}
}
if(pos.x+pos.y<=sizeWindow.x) {
if (sizeWindow.x - pos.x + pos.y <= sizeWindow.x) {
this.setDirection(4);
}
else{
this.setDirection(2);
}
}
}
开发者ID:FuriousCatInteractive,项目名称:AlektoroZombie,代码行数:19,代码来源:Player.java
示例8: reset
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Resets all the resources to 0.
*/
public void reset() {
for(int i = 0 ; i < this.size.y ; ++i) {
for(int j = 0 ; j < this.size.x ; ++j) {
getResources(new Vector2i(j, i)).reset();
}
}
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:11,代码来源:ResourcesMap.java
示例9: setResources
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Sets the resources on the tile.
* @param position : the position in tile coordinates
* @param resources : the new resources stack
*/
public void setResources(Vector2i position, ResourcesStack resources) {
// Get the row and modify the row.
List<ResourcesStack> row = this.resources.get(position.y);
row.set(position.x, resources);
// Set the row back in the two-dimensional array.
this.resources.set(position.y, row);
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:14,代码来源:ResourcesMap.java
示例10: cloneResourcesMap
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* clone ResourcesMap
* @return ResourcesMap :clone of the ResourcesMap
*/
public ResourcesMap cloneResourcesMap() {
ResourcesMap rMap = new ResourcesMap(new Vector2i(this.size.x,this.size.y));
for(int i = 0 ; i < this.size.y ; ++i) {
for(int j = 0 ; j < this.size.x ; ++j) {
rMap.setResources(new Vector2i(j,i), getResources(j,i).cloneResourcesStack());
}
}
return rMap;
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:16,代码来源:ResourcesMap.java
示例11: consumeResourcesForNeed
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Consumes one resource type on the resources map.
* @param resourcesMap : the resources map to place resources on
* @param resourceType : the type of resource to consume
* @param amount : the amount of resource to consume
* @param fillFactor : the fill factor to apply on the amount
*/
public void consumeResourcesForNeed(ResourcesMap resourcesMap, ResourceType resourceType, float amount, float fillFactor) {
float neededAmount = amount * fillFactor;
// We have to distribute the consummation on all the tiles.
for(int x = this.hitbox.left ; x < this.hitbox.left + this.hitbox.width ; ++x) {
for(int y = this.hitbox.top ; y < this.hitbox.top + this.hitbox.height ; ++y) {
// Check what is available on this tile.
ResourcesStack resourcesOnThisTile = resourcesMap.getResources(new Vector2i(x, y));
// Enough ?
float availableAmountOnThisTile = resourcesOnThisTile.get(resourceType);
if(availableAmountOnThisTile > neededAmount) {
// There is more than needed.
// Consume all we need.
resourcesOnThisTile.add(resourceType, -neededAmount);
neededAmount = 0.f;
}
else {
// Consume all available.
resourcesOnThisTile.set(resourceType, 0.f);
neededAmount -= availableAmountOnThisTile;
}
// Sets the resources back on the map.
resourcesMap.setResources(new Vector2i(x, y), resourcesOnThisTile);
}
}
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:37,代码来源:Building.java
示例12: getBuildingsAveragePosition
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Computes the average position of all the buildings of the given type (limited to the given number of buildings).
*
* @param buildings : the list of all the buildings
* @param buildingType : the buildings' type to take in account
* @param numberOfBuildingsToCount : the number of buildings to count for the average position
* @return The average position in tile coordinates.
*/
public Vector2i getBuildingsAveragePosition(Map<Integer, Building.BuildingType> buildings, Building.BuildingType buildingType, int numberOfBuildingsToCount) {
Vector2i position = new Vector2i(0, 0);
// Now sum the position of every building of the type specified.
for(Map.Entry<Integer, Building.BuildingType> entry : buildings.entrySet()) {
Building.BuildingType btype = entry.getValue();
if(btype == buildingType) {
Building building = null;
// Get the building.
for(Building b : this.buildings) {
if(b.getId() == entry.getKey()) {
building = b;
break;
}
}
// Add its position.
if(building != null) {
Vector2i centerPosition = new Vector2i(building.getHitbox().left + building.getHitbox().width / 2, building.getHitbox().top + building.getHitbox().height / 2);
position = Vector2i.add(position, centerPosition);
}
}
}
// Divide by the number of buildings counted to get the average position.
return new Vector2i((int)(position.x / numberOfBuildingsToCount), (int)(position.y / numberOfBuildingsToCount));
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:38,代码来源:Sim.java
示例13: getFurthestBuildingTo
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Returns the distance to the furthest building from the given point.
*
* @param buildings : the list of all the buildings
* @param buildingType : the buildings' type to take in account
* @param point : the point to compute distance from
* @return The distance between the furthest building of the given type to the given point.
*/
public float getFurthestBuildingTo(Map<Integer, Building.BuildingType> buildings, Building.BuildingType buildingType, Vector2i point) {
float radius = 0.f;
for(Map.Entry<Integer, Building.BuildingType> entry : buildings.entrySet()) {
Building.BuildingType btype = entry.getValue();
if(btype == buildingType) {
Building building = null;
// Get the building.
for(Building b : this.buildings) {
if(b.getId() == entry.getKey()) {
building = b;
break;
}
}
// Add its position.
if(building != null) {
Vector2i centerPosition = new Vector2i(building.getHitbox().left + building.getHitbox().width / 2, building.getHitbox().top + building.getHitbox().height / 2);
float distance = (float)Distance.euclidean(point, centerPosition);
if(distance > radius)
radius = distance;
}
}
}
return radius;
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:39,代码来源:Sim.java
示例14: spawnRoad
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Spawn road with the zone map
*/
public void spawnRoad() {
// run the map
for(int y = 0 ; y < this.zoneMap.getSize().y ; y++) {
for(int x = 0 ; x < this.zoneMap.getSize().x ; x++) {
// check if a zone type is road
if(this.zoneMap.getZoneMap().get(y).get(x).getType().equals(ZoneClass.ROAD)) {
// check if no building in this zone
for(int i = 0 ; i < this.buildings.size() ;) {
// if building remove it (ONLY if not a ROAD)
if(this.buildings.get(i).getType() != Building.BuildingType.ROAD && this.buildings.get(i).getHitbox().contains(x, y)) {
this.logGui.write("Removed building : " + this.buildings.get(i).getId(), LogGui.SUCCESS);
this.buildings.remove(this.buildings.get(i));
}
else {
i++;
}
}
// we spawn the road
this.buildings.add(new Building(BuildingType.ROAD, new Vector2i(x, y)));
}
}
}
this.logGui.write("New road(s) added.", true, LogGui.SUCCESS);
this.zoneDrawingGui.setNewRoadAdded(false);
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:31,代码来源:Sim.java
示例15: TileMap
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Constructor.
* @param size : size (in tiles) of the map
* @param sizeOfTile : the size of a tile in floating number
*/
public TileMap(Vector2i size, Vector2f sizeOfTile) {
this.size = size;
this.sizeOfTile = sizeOfTile;
this.typeColorMap = new HashMap<Tile.TileType, Color>();
this.vertexArray = new VertexArray(PrimitiveType.QUADS);
this.borderVertexArray = new VertexArray(PrimitiveType.LINES);
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:14,代码来源:TileMap.java
示例16: setTile
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Sets the type of the tile at the given position.
* @param position : position of the tile in tiles coordinates
* @param type : type of the tile
*/
public void setTile(Vector2i position, TileType type) {
// Only change if modifications.
if(this.tiles.get(position.y).get(position.x).tileType != type) {
this.tiles.get(position.y).get(position.x).tileType = type;
this.hasChanged = true;
}
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:13,代码来源:TileMap.java
示例17: LightLayer
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Constructor.
*
* @throws TextureCreationException
* @throws ShaderSourceException
* @throws IOException
*/
public LightLayer(Vector2i size) throws TextureCreationException, IOException, ShaderSourceException {
this.lastLightId = 0;
this.layerSize = size;
this.internalTexture = new RenderTexture();
this.internalTexture.create(size.x, size.y);
this.lightsVertexArrays = new HashMap<Integer, VertexArray>();
this.shader = new Shader();
this.shader.loadFromFile(Paths.get("res/shaders/blur.frag"), Shader.Type.FRAGMENT);
this.shader.setParameter("blur_radius", (float)0.005f);
this.alpha = 0;
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:21,代码来源:LightLayer.java
示例18: Tile
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Constructor.
* @param tileType : the type of the tile
* @param position : the position in tile coordinates
*/
public Tile(TileType tileType, Vector2i position) {
this.tileType = tileType;
this.id = Tile.lastId;
this.position = position;
// Increment the last id.
Tile.lastId++;
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:14,代码来源:Tile.java
示例19: ZoneMapLayer
import org.jsfml.system.Vector2i; //导入依赖的package包/类
public ZoneMapLayer(ZoneMap zones) {
this.zones = zones;
this.size = zones.getSize();
this.sizeOfTile = new Vector2i(16 ,16);
this.typeColorMap = new HashMap<Zone.ZoneClass, Color>();
this.vertexArray = new VertexArray(PrimitiveType.QUADS);
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:10,代码来源:ZoneMapLayer.java
示例20: ZoneDrawingGui
import org.jsfml.system.Vector2i; //导入依赖的package包/类
/**
* Constructor.
* @param textures : the textures manager
* @param fonts : the fonts manager
*/
public ZoneDrawingGui(TextureManager textures, FontManager fonts) {
this.checkboxes = new ArrayList<CheckBox>();
this.lastZoneClassChange = Time.ZERO;
this.position = new Vector2i(0,0);
int i = 0;
for(ZoneClass z : ZoneClass.values()) {
this.checkboxes.add(new CheckBox(27, 137 + i * 17, textures, fonts, z.toString(), z.hashCode()));
i++;
}
}
开发者ID:om3g4zell,项目名称:CityBuilderJSFML,代码行数:17,代码来源:ZoneDrawingGui.java
注:本文中的org.jsfml.system.Vector2i类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论