@Override protected void processEntity(Entity entity, float deltaTime) { if (_tile != null) { _batch.begin(); TextureRegion textureRegion = _tile.getCell().getTile().getTextureRegion(); Sprite sprite = new Sprite(textureRegion); if (!isLegalPlacement()) { sprite.setColor(Color.RED); sprite.setAlpha(0.5f); } else { sprite.setColor(Color.GREEN); sprite.setAlpha(0.5f); } sprite.setPosition(_tile.getCords().x, _tile.getCords().y); sprite.draw(_batch); _batch.end(); } }
public GameActor(TextureRegion actor_region,float x_pos,float y_pos,Color color,float width,float height) { actor_texture = actor_region; xpos = x_pos ; ypos = y_pos ; width_ =width ; height_ = height; actor_Sprite = new Sprite(actor_texture); actor_Sprite.setX(xpos); actor_Sprite.setY(ypos); if(color != null){ actor_Sprite.setColor(color);} actor_Sprite.setSize(width_, height_); actor_Sprite.setOrigin(width_/2, height_/2); setBounds(xpos, ypos, width_, height_); this.setTouchable(Touchable.enabled); }
@Override public void initialize() { //Allocate a pixmap big enough to accommodate four banks of pattern //tables (bg and spr each for all four banks) patternTablePixmap = new Pixmap(128, 1024, Pixmap.Format.RGBA8888); //Set blending to none so we can rewrite the pixmap and draw it to the //pattern table texture when graphics are regenerated. patternTablePixmap.setBlending(Pixmap.Blending.None); //Allocate a pixmap the size of one tile for live CHR-RAM updates. patternPixmap = new Pixmap(8, 8, Pixmap.Format.RGBA8888); patternPixmap.setBlending(Pixmap.Blending.None); patternTableTexture = new Texture(patternTablePixmap, false); TextureRegion[][] textureRegions = TextureRegion.split(patternTableTexture, 8, 8); patternTableSprites = new Sprite[128][16]; for(int row = 0; row < 128; row++) { for(int column = 0; column < 16; column++) { TextureRegion textureRegion = textureRegions[row][column]; patternTableSprites[row][column] = new Sprite(textureRegion); } } initializeMonochromePalette(); }
public GameActor(TextureRegion actor_region,float x_pos,float y_pos,Color color,float width,float height,boolean is_loading) { actor_texture = actor_region; xpos = x_pos ; ypos = y_pos ; width_ =width ; height_ = height; actor_Sprite = new Sprite(actor_texture); actor_Sprite.setX(xpos); actor_Sprite.setY(ypos); if(color != null){ actor_color = color ; actor_Sprite.setColor(actor_color);} actor_Sprite.setSize(width_, height_); }
public Trajectory(Orbiter orbiter) { this.orbiter = orbiter; int degreeIncrement = 10; speed = 10; Array<Orbiter> pathObjects = new Array<Orbiter>(); for(int i = 0; i < 360; i += degreeIncrement) { Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint(); orbiterBlueprint.angle = i; orbiterBlueprint.angularVelocity = speed; orbiterBlueprint.radius = orbiter.getRadius(); orbiterBlueprint.xTilt = orbiter.getXTilt(); orbiterBlueprint.zTilt = orbiter.getZTilt(); Sprite trajectoryDot = new Sprite(Scene.pixelTexture); Color color = new Color(); Color.rgba8888ToColor(color, orbiter.getColor()); trajectoryDot.setColor(color); trajectoryDot.setSize(2, 2); pathObjects.add(new Orbiter(trajectoryDot, orbiterBlueprint)); } path = new Ring(pathObjects); }
public MakeMadany(int sorah_no){ // TODO Auto-generated constructor stub goza_name_texture = book.get_region(suar_state[sorah_no-1]?"makah":"madinah"); Goza_name_sprite = new Sprite(goza_name_texture); height = tab_height ; width = height; Goza_name_sprite.setSize(width, height); no = sorah_no ; x = sorah_page_no_width+(sorah_tanzel_width-width)/2 ; y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1))); text_y_deferance=2*tab_height/3; surah_page_no = new TextActor(""+surah_page[no-1], null, sorah_page_no_width, TextAlign.align_cinter, tab_no_text_scale,0,text_y_deferance+y); }
public GameState(String name, String tmx, StateManager manager) { this.tmx = tmx; setManager(manager); if(name!=null) this.name = name; else this.name = ""; sprites = new ObjectMap<String, Sprite>(); animations = new ObjectMap<String, Animation<String>>(); fonts = new ObjectMap<String, BitmapFont>(); //TODO: test load to avoid repeats particle_effects = new ObjectMap<String, ParticleEffectPool>(); pvalues = new Array<String>(); time_scale = 1f; shaders = new ObjectMap<String, ShaderProgram>(); svalues = new Array<String>(); }
public SpaceObject(Sprite sprite, int color) { this.sprite = sprite; this.color = color; drawColor = new Color(color); if(sprite != null) { this.size = (int)sprite.getWidth(); } }
@Test public void testCloudJson() { Array<Orbiter> orbiters = new Array<>(); Orbiter.OrbiterBlueprint orbiterBlueprint = new Orbiter.OrbiterBlueprint(); orbiterBlueprint.angularVelocity = 70; int cloudObjectsCount = 10; for(int i = 0; i < cloudObjectsCount; i++) { orbiters.add(new Orbiter(new Sprite(), orbiterBlueprint)); } Cloud saveCloud = new Cloud(orbiters); String cloudJson = json.toJson(saveCloud); assertNotEquals("", cloudJson); Cloud loadCloud = json.fromJson(Cloud.class, cloudJson); assertNotEquals(null, loadCloud); assertEquals(cloudObjectsCount, loadCloud.getCloudObjects().size); assertEquals(70, loadCloud.getAngularVelocity()); }
public GozaName(int goza_no) { // TODO Auto-generated constructor stub goza_name_texture = book.get_region("s"+goza_no); Goza_name_sprite = new Sprite(goza_name_texture); width = sorah_name_width ; height = tab_height ; Goza_name_sprite.setSize(width, height); no = goza_no ; text_y_deferance=2*tab_height/3; x = (sorah_page_no_width+sorah_tanzel_width+ayat_widht)+sorah_tab_book_mark_width*3 ; y = book.sorah_scroll_pane.getScrollY()+Gdx.graphics.getHeight()-((tab_height*no+tab_pading_height*(no-1))); no_of_surah = new TextActor(no+"", null, tab_no_width, TextAlign.align_cinter,tab_no_text_scale,x+sorah_name_width, text_y_deferance+y); }
private void setupSplashImage() { DS.game.manager.load(splashImgFilename, Texture.class); manager.finishLoading(); splashLogo = new Sprite(DS.game.manager.get(splashImgFilename, Texture.class)); splashLogo.getTexture().setFilter(Texture.TextureFilter.Linear, Texture.TextureFilter.Linear); double SCALE = DS.T_WIDTH/splashLogo.getWidth(); if(DS.app_orientation == DS.ORIENTATION.PORTRAIT) { splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE)); } else { SCALE = DS.T_HEIGHT/splashLogo.getHeight(); splashLogo.setSize((float) (splashLogo.getWidth() * SCALE), (float) (splashLogo.getHeight() * SCALE)); } int imgX = (int)(DS.T_WIDTH/2.0 - splashLogo.getWidth()/2.0); int imgY = (int)(DS.T_HEIGHT/2.0 - splashLogo.getHeight()/2.0); Gdx.app.debug(ID, "splshlogo Width: " + splashLogo.getWidth()); Gdx.app.debug(ID, "splshlogo Height: " + splashLogo.getHeight()); Gdx.app.debug(ID, "imgX: " + imgX); Gdx.app.debug(ID, "imgY: " + imgY); splashLogo.setPosition(imgX, imgY); }
public void PlayAnimation(Sprite sprite, Animation animation, Rectangle newRegionOnTexture) { if (animation == null && this.animation == null) throw new GdxRuntimeException("No animation is currently playing."); // If this animation is already running, do not restart it. if (this.animation == animation) return; // Start the new animation. this.animation = animation; this.frameIndex = 0; this.animationTimeline = 0.0f; sprite.setRegionX((int) newRegionOnTexture.x); sprite.setRegionY((int) newRegionOnTexture.y); sprite.setRegionWidth((int) newRegionOnTexture.getWidth()); sprite.setRegionHeight((int) newRegionOnTexture.getHeight()); onAnimationChanged(); }
/** * Initialize position of sprite by the position of object from tiled map. * If size 's values is not zero, the sprite will be scaled by the new size * * @param sprite * the sprite will receive changes from tiled object * @param object * tiled object from tiled map * @param size */ public void initilizeTileObject(Sprite sprite, TiledObject object, float size) { sprite.setX(object.x + object.width / 2); sprite.setY(tileMapRenderer.getMapHeightUnits() - object.y - object.height / 2); if (size > 0) { float s = object.width / size; sprite.setScale(s); } }
@Override public void create() { float w = Gdx.graphics.getWidth(); float h = Gdx.graphics.getHeight(); camera = new OrthographicCamera(1, h/w); batch = new SpriteBatch(); texture = new Texture(Gdx.files.internal("data/libgdx.png")); texture.setFilter(TextureFilter.Linear, TextureFilter.Linear); TextureRegion region = new TextureRegion(texture, 0, 0, 200, 200); sprite = new Sprite(region); sprite.setSize(1f, sprite.getHeight() / sprite.getWidth()); sprite.setOrigin(sprite.getWidth()/2, sprite.getHeight()/2); sprite.setPosition(-.5f, -.5f); }
@Override public void create () { batch = new SpriteBatch(); img = new Texture("coche.png"); miCoche= new Sprite(img); miCoche.setPosition(0,20); miCoche.setSize(200,100); }
public Player() { super(0, 0); this.x = (float) (GameScreen.earth.getXCenter() + radius * Math.sin(angle)); this.y = (float) (GameScreen.earth.getYCenter() + radius * Math.cos(angle)); img = new Sprite(new Texture(Gdx.files.internal("player.png"))); shoot = new Sound[4]; for (int i = 1; i <= shoot.length; i++) { shoot[i - 1] = Gdx.audio.newSound(Gdx.files.internal("sound/shoot" + i + ".wav")); } }
public MenuScreen() { camera = new OrthographicCamera(); viewport = new FitViewport(Game.WIDTH, Game.HEIGHT, camera); viewport.apply(); camera.position.set(Game.WIDTH / 2, Game.HEIGHT / 2, 0); camera.update(); betaText = new BitmapFont(Gdx.files.internal("score.fnt"), Gdx.files.internal("score.png"), false); betaText.getData().setScale(0.35f); logo = new Sprite(new Texture("logo.png")); Random r = new Random(); background = new Particle[r.nextInt(55 - 45) + 45]; for (int i = 0; i < background.length; i++) { int size = r.nextInt(4) + 1; int x = r.nextInt(Game.WIDTH); int y = r.nextInt(Game.HEIGHT); background[i] = new Particle(x, y, 0, 0, -1, new Color(207 / 255f, 187 / 255f, 20 / 255f, 1f), size); } musicMuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_muted.png"))); musicUnmuted = new Sprite(new Texture(Gdx.files.internal("buttons/music_unmuted.png"))); play = new CenteredButton(500, "buttons/play.png"); music = new Button(Game.WIDTH - 130, 15, Game.musicMuted() ? musicMuted : musicUnmuted); music.setScale(4f); }
public void init() { topBunSprite = new Sprite(AssetDoctor.getSprite("burger_top_bun")); burgerSprite = new Sprite(AssetDoctor.getSprite("burger_burger")); lettuceSprite = new Sprite(AssetDoctor.getSprite("burger_lettuce")); bottomBunSprite = new Sprite(AssetDoctor.getSprite("burger_bottom_bun")); resizeSprite(topBunSprite); resizeSprite(lettuceSprite); resizeSprite(burgerSprite); resizeSprite(bottomBunSprite); topBunSprite.setPosition(x - topBunSprite.getWidth()/2.0f, y - topBunSprite.getHeight()/2.0f + 20.0f); lettuceSprite.setPosition(x - lettuceSprite.getWidth()/2.0f, y - lettuceSprite.getHeight()/2.0f); burgerSprite.setPosition(x - burgerSprite.getWidth()/2.0f, y - burgerSprite.getHeight()/2.0f - 10.0f); bottomBunSprite.setPosition(x - bottomBunSprite.getWidth()/2.0f, y - bottomBunSprite.getHeight()/2.0f - 20.0f); CURRENT_STATE = STATE.LIVE; }
private void drawHealthBar(HealthComponent healthComp, PositionComponent pos) { final float healthBarHeight = Assets.enemyRedHealthbarBG.getHeight(); final float healthBarWidth = Assets.enemyRedHealthbarBG.getWidth(); // getting the scale ratio final double ratio = healthBarWidth / healthComp.maxHealth; Sprite spriteBg = Assets.enemyRedHealthbarBG; Sprite sprite = Assets.enemyGreenHealthbarBG; // todo center hp bar sprite.setPosition(pos.position.x, pos.position.y); spriteBg.setPosition(pos.position.x, pos.position.y); if(healthComp.health > 0) sprite.setSize((float) (ratio * healthComp.health), healthBarHeight); // 100 % if (healthComp.health <= healthComp.maxHealth) sprite.setColor(0, 0.75f, 0, 1f); // 75 % if (healthComp.health <= 0.75 * healthComp.maxHealth) sprite.setColor(Color.YELLOW); // 50% if (healthComp.health <= 0.50 * healthComp.maxHealth) sprite.setColor(Color.ORANGE); // 25% if (healthComp.health <= 0.25 * healthComp.maxHealth) sprite.setColor(Color.BROWN); // if enemy isn't hurt don't draw health. if (healthComp.health != healthComp.maxHealth) { _batch.begin(); spriteBg.draw(_batch); sprite.draw(_batch); _batch.end(); } }
/** * Returns a shaded sprite for coloring the ability icons. Controlled by the {@link Character} class. * * @param ability for the overlay sprite * @return the overlay sprite */ public Sprite getAbilityOverlaySprite(int ability) { CharacterComponent characterComponent = arcadeWorld.getEntityWorld().getMapper(CharacterComponent.class).get(entityId); Color color; if ((color = characterComponent.character.getAbilityOverlay(ability)) != null) abilityOverlaySprites[ability].setColor(color); else abilityOverlaySprites[ability].setColor(0, 0, 0, 0); return abilityOverlaySprites[ability]; }
private void setup_a_sprites(TextureAtlas atlas) { a_sprites.add(AssetDoctor.loadSprite_ATLAS("border", atlas.createSprite("border"))); for(Sprite s : b_sprites) { s.setSize(s.getWidth()*DS.SCALE, s.getHeight()*DS.SCALE); } }
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int scrollX, int scrollY, float splitYStart, float splitYEnd) { int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1; boolean toggleNametableEarly = false; if (scrollY > 239 && scrollY <= 255) { scrollY -= 16; toggleNametableEarly = true; } int coarseScrollX = scrollX >> 3; int coarseScrollY = scrollY >> 3; int fineScrollX = scrollX & 7; int fineScrollY = scrollY & 7; int nameTableX = coarseScrollX; int nameTableY = coarseScrollY; int actualNameTableX; int actualNameTableY; int screenX = 0; int screenY = 8; int nameTableRowCount = fineScrollY == 0 ? 30 : 31; int nameTableColumnCount = 33; int nameTable; while (nameTableColumnCount > 0) { screenY = 0; nameTableRowCount = fineScrollY == 0 ? 30 : 31; nameTableY = coarseScrollY; nameTable = (ggvm.getNametableAddress() == Ppu.NAME_TABLE_0_BASE_ADDRESS) ? 0 : 1; if (toggleNametableEarly) { nameTable ^= 1; } while (nameTableRowCount > 0) { actualNameTableX = nameTableX % 32; actualNameTableY = nameTableY % 30; int nameTableAddress = nameTable == 1 ? Ppu.NAME_TABLE_1_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS; int attributeTableAddress = nameTableAddress == 1 ? Ppu.ATTRIBUTE_TABLE_1_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS; int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY); int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY); int indexRow = index >> 4; int indexColumn = index & 0x0f; Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn]; sprite.setColor(0, attributes[attribute], 0, 0); //if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) { sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY); sprite.draw(spriteBatch); //} screenY += 8; nameTableY++; nameTableRowCount--; } screenX += 8; nameTableX++; nameTableColumnCount--; } }
private void drawNametable(GGVm ggvm, SpriteBatch spriteBatch, int startingNametableAddress, int scrollX, int scrollY, float splitYStart, float splitYEnd) { int patternTable = ggvm.getBackgroundPatternTableAddress() == 0 ? 0 : 1; int coarseScrollX = scrollX >> 3; int coarseScrollY = scrollY >> 3; int fineScrollX = scrollX & 7; int fineScrollY = scrollY & 7; int nameTableX = coarseScrollX; int nameTableY = coarseScrollY; int actualNameTableX; int actualNameTableY; int screenX = 0; int screenY = 0; int nameTableRowCount = fineScrollY == 0 ? 30 : 31; int nameTableColumnCount; int nameTable; while (nameTableRowCount > 0) { screenX = 0; nameTableColumnCount = fineScrollX == 0 ? 32 : 33; nameTableX = coarseScrollX; nameTable = (startingNametableAddress == Ppu.NAME_TABLE_0_BASE_ADDRESS || startingNametableAddress == Ppu.NAME_TABLE_2_BASE_ADDRESS) ? 0 : 1; while (nameTableColumnCount > 0) { actualNameTableX = nameTableX % 32; actualNameTableY = nameTableY % 30; int whichNameTable = nameTable ^ ((nameTableX >> 5) & 1); int nameTableAddress = whichNameTable == 1 ? Ppu.NAME_TABLE_1_BASE_ADDRESS : Ppu.NAME_TABLE_0_BASE_ADDRESS; int attributeTableAddress = whichNameTable == 1 ? Ppu.ATTRIBUTE_TABLE_1_BASE_ADDRESS : Ppu.ATTRIBUTE_TABLE_0_BASE_ADDRESS; int index = ggvm.getNametableTile(nameTableAddress, actualNameTableX, actualNameTableY); int attribute = ggvm.getAttributeForNametableTile(attributeTableAddress, actualNameTableX, actualNameTableY); int indexRow = index >> 4; int indexColumn = index & 0x0f; Sprite sprite = patternTableManager.getSprite(patternTable, indexRow, indexColumn);//patternTableSprites[patternTableOffset * 16 + indexRow][indexColumn]; sprite.setColor(0, attributes[attribute], 0, 0); if (!GGVmRegisterStatusBar.isSprite0HitStatusBarEnabled() || (screenY >= splitYStart && screenY < splitYEnd)) { sprite.setPosition(screenX - fineScrollX, 232 - screenY + fineScrollY); sprite.draw(spriteBatch); } screenX += 8; nameTableX++; nameTableColumnCount--; } screenY += 8; nameTableY++; nameTableRowCount--; } }
/** * Initialisierung * * @param game zeigt auf das SchoolGame, dass das Spiel verwaltet */ @Override public void create(SchoolGame game) { this.game = game; batch = new SpriteBatch(); Texture splashImg = new Texture(Gdx.files.internal("data/misc/splashscreen.png")); screenSprite = new Sprite(splashImg); screenSprite.setPosition(-screenSprite.getWidth() / 2, -screenSprite.getHeight() / 2); screenSprite.setAlpha(0); timer = SHOW_TIME + FADE_TIME * 2; }
public static GameObject createGameObjectWithBox2DBody(Vector2 gameObjectPos, Texture texture, Vector3 densityFrictionRestitution, BodyDef.BodyType bodyType, Shape.Type shapeType, World world) { GameObject gameObject = new GameObject(); gameObject.setPosition(gameObjectPos.x, gameObjectPos.y); gameObject.setTexture(texture); gameObject.setSprite(new Sprite(texture)); gameObject.getSprite().setOriginCenter(); gameObject.setWorld(world); BodyCreator bodyCreator = new BodyCreator(); gameObject.setBody(bodyCreator.createBody(new Vector2(gameObject.getX(), gameObject.getY()), texture, bodyType, world, shapeType, densityFrictionRestitution)); bodyCreator = null; return gameObject; }
private void createPlanet(int velDir) { Pixmap pixmap = generatePlanetPixmap(1024); Sprite planet = new Sprite(new Texture(pixmap)); int size = MathUtils.random(100, 148); planet.setSize(size, size); planet.setPosition(CENTER_X - planet.getWidth() / 2, CENTER_Y - planet.getHeight() / 2); this.planet = new Planet(planet, pixmap, velDir); spaceObjects.add(this.planet); }
private void loadPlanet(Json json, JsonValue jsonData) { planet = json.readValue("planet", Planet.class, jsonData); Pixmap loadPixmap = new Pixmap(1024, 1024, Pixmap.Format.RGBA8888); int index = 0; for(int x = 0; x < 1024; x++) { for (int y = 0; y < 1024; y++) { int color = 0; switch (planet.getTextureString().charAt(index)) { case 'd': color = Color.rgba8888(47f / 255f, 86f / 255f, 118f / 255f, 1f); break; case 'o': color = Color.rgba8888(62f / 255f, 120f / 255f, 160f / 255f, 1f); break; case 'l': color = Color.rgba8888(146f / 255f, 209f / 255f, 135f / 255f, 1f); break; } index++; loadPixmap.setColor(color); loadPixmap.drawPixel(x, y); } } Sprite sprite = new Sprite(new Texture(loadPixmap)); sprite.setSize(planet.getSize(), planet.getSize()); sprite.setPosition(CENTER_X - planet.getSize() / 2, CENTER_Y - planet.getSize() / 2); planet = new Planet(sprite, loadPixmap, objectGenerator.getVelDir()); spaceObjects.add(planet); }
@Override public void read(Json json, JsonValue jsonData) { super.read(json, jsonData); setSprite(new Sprite()); int size = json.readValue("size", Integer.class, jsonData); getSprite().setSize(size, size); int x = json.readValue("xPos", Integer.class, jsonData); int y = json.readValue("yPos", Integer.class, jsonData); getSprite().setPosition(x, y); }
public Orbiter(Sprite sprite, OrbiterBlueprint blueprint, int color) { super(sprite, color); this.angularVelocity = blueprint.angularVelocity; this.zTilt = blueprint.zTilt; this.xTilt = blueprint.xTilt; this.angle = blueprint.angle; this.radius = blueprint.radius; this.yOffset = blueprint.yOffset; // setColor(color); initializeMatrices(); }
public Planet(Sprite sprite, Pixmap pixmap, int direction) { super(sprite); this.pixmap = pixmap; this.direction = direction; rotationSpeed = 1/50f; radius = sprite.getWidth()/2; planetShader = new ShaderProgram(Gdx.files.internal("shaders/planet.vsh"), Gdx.files.internal("shaders/planet.fsh")); if(!planetShader.isCompiled()) { Gdx.app.error("Planet Shader Error", "\n" + planetShader.getLog()); } }
public BookMarks(int sorah_no , int type_from1_to3) { // TODO Auto-generated constructor stub bookmark_type = type_from1_to3 ; bookmark_texture = book.images_textures_atlas.findRegion("bookmark"+bookmark_type); bookmark_sprite = new Sprite(bookmark_texture) ; bookmark_sprite.setSize(sorah_tab_book_mark_width, tab_height); no = sorah_no ; }
public Anto(OrthographicCamera camera){ this.camera = camera; this.texture = new Texture("Antoninho.png"); this.showUp = false; this.sprite = new Sprite(texture); this.sprite.setSize(camera.viewportWidth/2.5f,texture.getHeight()/2.5f); this.sprite.setPosition(-camera.viewportWidth, 0); boundsTop = new Rectangle(sprite.getX()-20, sprite.getY()-20 , sprite.getWidth()-20, sprite.getHeight()-20); }
public void spawnAnto(float x, float y, Texture texture){ this.texture = texture; this.showUp = true; this.sprite = new Sprite(texture); this.sprite.setSize(camera.viewportWidth/2,texture.getHeight()/2); this.sprite.setPosition(x, y); }
public WeakEnemy(int choiceToMove, float xOffset, float yOffset) { health = 4; this.choiceToMove = choiceToMove; posX = xOffset; posY = Gdx.graphics.getHeight() + 50 + yOffset; texture = AssetLoader.assetManager.get("weakenemy.png", Texture.class); sprite = new Sprite(texture); sprite.setOriginCenter(); sprite.setRotation(180); sprite.setPosition(posX, posY); delayWithAttack = MathUtils.random(70f)+ 50f; delay = delayWithAttack; switch(choiceToMove) { case 0: posX = -30 + xOffset; bulletType = BulletType.ROCKET; break; case 1: posX = Gdx.graphics.getWidth() + 30 + xOffset; bulletType = BulletType.ION; break; case 2: posX = Gdx.graphics.getWidth() / 2 + xOffset; bulletType = BulletType.ROCKET; break; case 3: posX = Gdx.graphics.getWidth() / 2 + xOffset; bulletType = BulletType.ION; break; } }
public DoaaActor() { doaa_first = book.images_textures_atlas.findRegion("d1"); doaa_second = book.images_textures_atlas.findRegion("d2"); doaa_s_first = new Sprite(doaa_first) ; doaa_s_second = new Sprite(doaa_second); doaa_s_first.setSize(book.screen_width, book.screen_height); doaa_s_second.setSize(book.screen_width, book.screen_height); }
@Override public void init() { randgen = new Random(); manager = DS.game.manager; a_sprites = new ArrayList<Sprite>(); b_sprites = new ArrayList<Sprite>(); c_sprites = new ArrayList<Sprite>(); }
public Mob(@NotNull String spriteName, int health, @NotNull ItemDrop... deathDrops) { super(new Sprite()); dir = Direction.DOWN; this.maxHealth = health; this.health = health; this.itemDrops = deathDrops; blinker = new FrameBlinker(5, 1, false); animator = new MobAnimationController(this, spriteName); }
public Entity(Sprite sprite) { this.sprite = sprite; int eid; do { eid = MathUtils.random.nextInt(); } while(takenIDs.containsKey(eid)); this.eid = eid; takenIDs.put(eid, this); }
public LaserProjectile() { setProjectileSprite(new Sprite(Assets.laserSmall)); setVelocity(600); setOffsetX(8); setOffsetY(8); setSoundEffect(Assets.laserTurretFire); }
public Meteorite(Sprite[] textures, Sprite[] warning, Sound sound) { super(0, 0); this.sound = sound; Random r = new Random(); int direction = r.nextInt(360 + 1); health = r.nextInt(2) + 3; float tempVelY = (float) (10 * Math.cos(Math.toRadians(direction))); float tempVelX = (float) (10 * Math.sin(Math.toRadians(direction))); if (r.nextInt(2) == 0) tempVelX *= -1; if (r.nextInt(2) == 0) tempVelY *= -1; Rectangle collision = new Rectangle((int) GameScreen.earth.getXCenter(), (int) GameScreen.earth.getYCenter(), radius * 2, radius * 2); Rectangle screen = new Rectangle(0, 0, Game.WIDTH, Game.HEIGHT); while (collision.overlaps(screen)) { collision.setPosition(collision.x + tempVelX, collision.y + tempVelY); } warningRect = new Rectangle(collision.x, collision.y, 50, 50); while (!warningRect.overlaps(screen)) { warningRect.setPosition(collision.x - tempVelX * 15, collision.y - tempVelY * 15); } x = (float) collision.getX(); y = (float) collision.getY(); float xSpeed = (Game.WIDTH / 2 - x) / 1.0f; float ySpeed = (Game.HEIGHT / 2 - y) / 1.0f; float factor = (float) (speed / Math.sqrt(xSpeed * xSpeed + ySpeed * ySpeed)); xSpeed *= factor; ySpeed *= factor; velX = xSpeed; velY = ySpeed; this.collision = new Circle(x - radius, y - radius, radius); this.img = textures; this.warning = warning; warningTime = System.currentTimeMillis() + 3000; }