List of usage examples for com.badlogic.gdx.graphics Color Color
public Color(float r, float g, float b, float a)
From source file:com.badlogic.gdx.graphics.g3d.test.StillModelViewerGL20.java
License:Apache License
@Override public void create() { long start = System.nanoTime(); model = ModelLoaderRegistry.loadStillModel(Gdx.files.internal(fileName)); Gdx.app.log("StillModelViewer", "loading took: " + (System.nanoTime() - start) / 1000000000.0f); if (textureFileNames.length != 0) { textures = new Texture[textureFileNames.length]; for (int i = 0; i < textureFileNames.length; i++) { textures[i] = new Texture(Gdx.files.internal(textureFileNames[i]), i > 0 ? false : true); }//from w ww. j ava2s.c o m } model.getBoundingBox(bounds); float len = bounds.getDimensions().len(); System.out.println("bounds: " + bounds); cam = new PerspectiveCamera(60, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(bounds.getCenter().cpy().add(len / 2, len / 2, len / 2)); cam.lookAt(bounds.getCenter().x, bounds.getCenter().y, bounds.getCenter().z); cam.near = 0.1f; cam.far = 64; batch = new SpriteBatch(); font = new BitmapFont(); // shader1 = ShaderLoader.createShader("light", "light"); // shader2 = ShaderLoader.createShader("vertexpath", "vertexpath"); lightManager = new LightManager(4, LightQuality.VERTEX); lightManager.dirLight = new DirectionalLight(); lightManager.dirLight.color.set(0.09f, 0.07f, 0.09f, 0); lightManager.dirLight.direction.set(-.4f, -1, 0.03f).nor(); for (int i = 0; i < 4; i++) { PointLight l = new PointLight(); l.position.set(-MathUtils.random(8) + 4, MathUtils.random(3), -MathUtils.random(6) + 3); l.color.r = MathUtils.random(); l.color.b = MathUtils.random(); l.color.g = MathUtils.random(); l.intensity = 3; lightManager.addLigth(l); } lightManager.ambientLight.set(.03f, 0.05f, 0.06f, 0); protoRenderer = new PrototypeRendererGL20(lightManager); protoRenderer.cam = cam; MaterialAttribute c1 = new ColorAttribute(new Color(0.5f, 0.51f, 0.51f, 1.0f), ColorAttribute.specular); MaterialAttribute c2 = new ColorAttribute(new Color(0.95f, 0.95f, 0.95f, 1.0f), ColorAttribute.diffuse); MaterialAttribute t0 = new TextureAttribute(textures[0], 0, TextureAttribute.diffuseTexture); Material material = new Material("basic", c1, c2, t0); model.setMaterial(material); instance = new StillModelNode(); instance.getTransform().translate(-len / 2, -1, 2); instance.radius = bounds.getDimensions().len() / 2; instance2 = new StillModelNode(); instance2.getTransform().translate(len / 2, -1, -7); instance2.radius = instance.radius; }
From source file:com.badlydrawngames.veryangryrobots.ParticleAdapter.java
License:Apache License
public ParticleAdapter(World world, ParticleManager particleManager) { this.world = world; this.particleManager = particleManager; shotExplosionColor = new Color(1.0f, 0.5f, 0.0f, 1.0f); }
From source file:com.bombinggames.clonkrageremade.ClonkRage.java
@Override public void create() { view = new View(this); devtools = new DevTools(0, 0); //koordinatensystem nach unten zeigend foreGround = new Pixmap(1920, 1080, Pixmap.Format.RGBA8888); //foreGround.setColor(new Color(0.4f, 0.5f, 0.9f, 1)); //foreGround.fill(); backGround = new Pixmap(1920, 1080, Pixmap.Format.RGBA8888); backGround.setColor(new Color(0.4f, 0.5f, 0.9f, 1)); backGround.fill();/*from w w w. j ava 2s.c o m*/ int surfaceheight = 300; int amplitude = 50; float width = (float) (Math.PI / 300f); float colornoise = 0.3f; int curvatureHeight = 30; for (int x = 0; x < foreGround.getWidth(); x++) { //y position of surface int surface = (int) (Math.sin(width * x) * amplitude + surfaceheight); for (int y = 0; y < surface; y++) { float topCurvature = 0;//brightness of added top curvature if (y > surface - curvatureHeight) {//is in area of curvature topCurvature = (1 - (y - surface) / (float) curvatureHeight) * 0.5f; } int color = ((int) ((topCurvature + 0.4f * (1 - colornoise / 2 + colornoise * Math.random())) * 255) << 24)//R | ((int) ((topCurvature + 0.3f * (1 - colornoise / 2 + colornoise * Math.random())) * 255) << 16)//G | ((int) ((topCurvature + 0.2f * (1 - colornoise / 2 + colornoise * Math.random())) * 255) << 8)//B | 1 * 255;//A if (x < 500) { foreGround.drawPixel(x, y, color); } backGround.drawPixel(x, y, ((int) ((0.2f * (1 - colornoise / 2 + colornoise * Math.random())) * 255) << 24)//R | ((int) ((0.1f * (1 - colornoise / 2 + colornoise * Math.random())) * 255) << 16)//G | ((int) ((0.1f * (1 - colornoise / 2 + colornoise * Math.random())) * 255) << 8)//B | 1 * 255//A ); } } spawnEnts(); }
From source file:com.bombinggames.isthisme.GameScreen.java
@Override public void render(float delta) { delta *= 1000f;//to ms if (!hitting) { boolean walking = false; if (Gdx.input.isKeyPressed(Keys.RIGHT) || Gdx.input.isKeyPressed(Keys.D)) { p1Pos.x += delta * walkingspeed; walking = true;/*from www .ja va 2s . c o m*/ } if (Gdx.input.isKeyPressed(Keys.LEFT) || Gdx.input.isKeyPressed(Keys.A)) { p1Pos.x -= delta * walkingspeed; walking = true; } if (escape || Gdx.input.isKeyPressed(Keys.UP) || Gdx.input.isKeyPressed(Keys.W)) { p1Pos.y += delta * walkingspeed; walking = true; } if (!escape && (Gdx.input.isKeyPressed(Keys.DOWN) || Gdx.input.isKeyPressed(Keys.S))) { p1Pos.y -= delta * walkingspeed; walking = true; } if (walking) { time += delta; } } if (hitting) hitTimer += delta; if (hitTimer > hitAnimation.getAnimationDuration()) hitting = false; if (hitTimer > hitAnimation.getFrameDuration()) impact(); if (Gdx.input.isKeyPressed(Keys.SPACE) || Gdx.input.isButtonPressed(Buttons.LEFT)) { startAttack(); } if (!deathmode && p1Pos.y > 200) p1Pos.y = 200; if (p1Pos.y < 10) p1Pos.y = 10; if (deathmode && p1Pos.x > 850) p1Pos.x = 850; if (deathmode && p1Pos.y > 650 && p1Pos.y < 900) { scream.play(); p1Pos.y = 900; } if (p1Pos.y > 1900) { Gdx.app.exit(); } if (p1Pos.x > 1280) { fiep.stop(); music.stop(); music.dispose(); game.setScreen(new Blowjob(game)); return; } if (walls != null && p1Pos.y < 1000) { if (shakeWallRight) shakeWall += delta / 30f; else { shakeWall -= delta / 30f; } if (shakeWall > 2) shakeWallRight = false; if (shakeWall < -2) shakeWallRight = true; walls.setRotation(shakeWall); } if (stream != null) { stream.setX(stream.getX() + delta / 40f); } if (flash != null) { flashTimer -= delta; if (flashTimer < 0) { flashTimer = 200; flash.setRotation((float) (Math.random() * 20f - 5f)); } flash.setAlpha(flashTimer / 200f); } Dude nearestAliveDude = dudeList.get(0); if (!nearestAliveDude.isAlive()) nearestAliveDude = null; for (Dude dude : dudeList) { dude.update(delta); if (dude.isAlive() && (nearestAliveDude == null || dude.getPosition().dst2(p1Pos) < nearestAliveDude.getPosition().dst2(p1Pos))) nearestAliveDude = dude; } float fiepVolume = 0.01f; if (nearestAliveDude == null) { fiep.setVolume(fiepInstance, 0); } else { float divisor = (nearestAliveDude.getPosition().dst(p1Pos) - 40); if (divisor > 0) fiepVolume = 1f / divisor; else fiepVolume = 1; if (fiepVolume > 1) fiepVolume = 1; if (fiepVolume < 0.01f) fiepVolume = 0.01f; fiep.setVolume(fiepInstance, fiepVolume); } music.setVolume(1f / (fiepVolume / 2 + 0.5f) - 0.8f); Color rage = new Color(0, (float) (1 - Math.random() * 0.5f), (float) (1 - Math.random() * 0.5f), 1) .mul(fiepVolume + 0.2f); rage.a = (float) (1 - Math.random() * 0.3f); overlay.setColor(rage); //render batch.begin(); background.draw(batch); if (stream != null) stream.draw(batch); if (street != null) street.draw(batch); for (Dude dude : dudeList) { dude.draw(batch); } if (hitting) { batch.draw(hitAnimation.getKeyFrame(hitTimer), p1Pos.x, p1Pos.y); } else { batch.draw(walkinAnimation.getKeyFrame(time), p1Pos.x, p1Pos.y); } if (walls != null) walls.draw(batch); if (flash != null) flash.draw(batch); overlay.draw(batch); batch.end(); }
From source file:com.codefiddler.libgdx.tetris.domain.Tetrimino.java
License:Apache License
public static Tetrimino getT() { return new Tetrimino(T, new Color(0x139 / 255f, 0x69 / 255f, 0x19 / 255f, 0)); }
From source file:com.coder5560.game.ui.MyDialog.java
License:Apache License
private void initialize() { setModal(true);/* www . java2 s.com*/ back2 = new Image(new NinePatchDrawable( new NinePatch(new NinePatch(Assets.instance.getRegion("ninepatch2"), 4, 4, 4, 4), new Color(240 / 255f, 240 / 255f, 240 / 255f, 1)))); addActor(back2); defaults().space(6); add(contentTable = new Table(skin)).expand().fill(); row(); add(buttonTable = new Table(skin)); contentTable.defaults().space(6); buttonTable.defaults().space(6); buttonTable.addListener(new ChangeListener() { public void changed(ChangeEvent event, Actor actor) { if (!values.containsKey(actor)) return; while (actor.getParent() != buttonTable) actor = actor.getParent(); result(values.get(actor)); if (!cancelHide) hide(); cancelHide = false; } }); addListener(new FocusListener() { public void keyboardFocusChanged(FocusEvent event, Actor actor, boolean focused) { if (!focused) focusChanged(event); } public void scrollFocusChanged(FocusEvent event, Actor actor, boolean focused) { if (!focused) focusChanged(event); } private void focusChanged(FocusEvent event) { Stage stage = getStage(); if (isModal() && stage != null && stage.getRoot().getChildren().size > 0 && stage.getRoot().getChildren().peek() == MyDialog.this) { // Dialog // is // top // most // actor. Actor newFocusedActor = event.getRelatedActor(); if (newFocusedActor != null && !newFocusedActor.isDescendantOf(MyDialog.this)) event.cancel(); } } }); }
From source file:com.company.minery.utils.spine.Skeleton.java
License:Open Source License
public Skeleton(SkeletonData data) { if (data == null) throw new IllegalArgumentException("data cannot be null."); this.data = data; bones = new Array(data.bones.size); for (BoneData boneData : data.bones) { Bone parent = boneData.parent == null ? null : bones.get(data.bones.indexOf(boneData.parent, true)); bones.add(new Bone(boneData, this, parent)); }/*from w ww.j a v a 2 s . c o m*/ slots = new Array(data.slots.size); drawOrder = new Array(data.slots.size); for (SlotData slotData : data.slots) { Bone bone = bones.get(data.bones.indexOf(slotData.boneData, true)); Slot slot = new Slot(slotData, bone); slots.add(slot); drawOrder.add(slot); } ikConstraints = new Array(data.ikConstraints.size); for (IkConstraintData ikConstraintData : data.ikConstraints) ikConstraints.add(new IkConstraint(ikConstraintData, this)); color = new Color(1, 1, 1, 1); updateCache(); }
From source file:com.company.minery.utils.spine.Slot.java
License:Open Source License
Slot(SlotData data) { this.data = data; bone = null; color = new Color(1, 1, 1, 1); }
From source file:com.digitale.utils.Actors.java
License:Open Source License
public static Actor topToast(final String text, final float time, final Skin skin) { final Window window = new Window("", skin); final Color windowColor = new Color(1, 0, 0, 1); window.setMovable(false);//from w ww . j av a2 s. co m window.defaults().spaceBottom(5); Label toastLabel = new Label(text, skin); toastLabel.setAlignment(Align.LEFT); toastLabel.setWrap(true); window.row().fillX().expandX(); window.add(toastLabel).fillX().padLeft(10); window.invalidate(); window.width = Gdx.app.getGraphics().getWidth() * 0.95f; window.height = toastLabel.getTextBounds().height + 20 + window.getStyle().titleFont.getLineHeight(); window.x = Gdx.app.getGraphics().getWidth() * 0.5f - window.width * 0.5f; float outsideY = Gdx.app.getGraphics().getHeight() + window.height; float insideY = Gdx.app.getGraphics().getHeight() - window.height + window.getStyle().titleFont.getLineHeight(); window.y = outsideY; final TimelineAnimation timelineAnimation = Builders.animation( // Builders.timeline() // .value(Builders.timelineValue(window, Scene2dConverters.actorPositionTypeConverter) // .keyFrame(0f, new float[] { window.x, outsideY }, // InterpolationFunctions.linear(), InterpolationFunctions.easeIn()) // .keyFrame(1f, new float[] { window.x, insideY }) // .keyFrame(4f, new float[] { window.x, insideY }, // InterpolationFunctions.linear(), InterpolationFunctions.easeOut()) // .keyFrame(5f, new float[] { window.x, outsideY }) // ) // ) // .started(true) // .delay(0f) // .speed(5f / time) // .build(); window.action(new ActionAdapter() { @Override public void act(float delta) { timelineAnimation.update(delta); if (timelineAnimation.isFinished()) { window.getStage().removeActor(window); } } }); return window; }
From source file:com.esotericsoftware.spine.SkeletonViewer.java
License:Open Source License
void loadSkeleton(FileHandle skeletonFile, boolean reload) { if (skeletonFile == null) return;/*from w w w .j a v a 2 s .c om*/ // A regular texture atlas would normally usually be used. This returns a white image for images not found in the atlas. Pixmap pixmap = new Pixmap(32, 32, Format.RGBA8888); pixmap.setColor(new Color(1, 1, 1, 0.33f)); pixmap.fill(); final AtlasRegion fake = new AtlasRegion(new Texture(pixmap), 0, 0, 32, 32); pixmap.dispose(); String atlasFileName = skeletonFile.nameWithoutExtension(); if (atlasFileName.endsWith(".json")) atlasFileName = new FileHandle(atlasFileName).nameWithoutExtension(); FileHandle atlasFile = skeletonFile.sibling(atlasFileName + ".atlas"); if (!atlasFile.exists()) atlasFile = skeletonFile.sibling(atlasFileName + ".atlas.txt"); TextureAtlasData data = !atlasFile.exists() ? null : new TextureAtlasData(atlasFile, atlasFile.parent(), false); TextureAtlas atlas = new TextureAtlas(data) { public AtlasRegion findRegion(String name) { AtlasRegion region = super.findRegion(name); return region != null ? region : fake; } }; try { String extension = skeletonFile.extension(); if (extension.equalsIgnoreCase("json") || extension.equalsIgnoreCase("txt")) { SkeletonJson json = new SkeletonJson(atlas); json.setScale(ui.scaleSlider.getValue()); skeletonData = json.readSkeletonData(skeletonFile); } else { SkeletonBinary binary = new SkeletonBinary(atlas); binary.setScale(ui.scaleSlider.getValue()); skeletonData = binary.readSkeletonData(skeletonFile); } } catch (Exception ex) { ex.printStackTrace(); ui.toast("Error loading skeleton: " + skeletonFile.name()); lastModifiedCheck = 5; return; } skeleton = new Skeleton(skeletonData); skeleton.setToSetupPose(); skeleton = new Skeleton(skeleton); skeleton.updateWorldTransform(); state = new AnimationState(new AnimationStateData(skeletonData)); this.skeletonFile = skeletonFile; Preferences prefs = Gdx.app.getPreferences("spine-skeletontest"); prefs.putString("lastFile", skeletonFile.path()); prefs.flush(); lastModified = skeletonFile.lastModified(); lastModifiedCheck = checkModifiedInterval; // Populate UI. ui.skeletonLabel.setText(skeletonFile.name()); { Array<String> items = new Array(); for (Skin skin : skeletonData.getSkins()) items.add(skin.getName()); ui.skinList.setItems(items); } { Array<String> items = new Array(); for (Animation animation : skeletonData.getAnimations()) items.add(animation.getName()); ui.animationList.setItems(items); } // Configure skeleton from UI. skeleton.setSkin(ui.skinList.getSelected()); state.setAnimation(0, ui.animationList.getSelected(), ui.loopCheckbox.isChecked()); if (reload) ui.toast("Reloaded."); }