public static void load(GLGame game) { //Load Textures and define texture regions LoadFonts/////////// Assets.game = game; splashscreen = new Texture("splash.png"); wrn = new Texture("wrg.png"); side = new Texture("side.png"); loadscreen = new TextureRegion(splashscreen, 1, 205, 800, 600); circ = new TextureRegion(side, 0, 0,600 ,1000); loading = new TextureRegion(splashscreen, 803, 705, 156, 55); Settings.load(); Game.gd = new GameData(Settings.musicEnabled,Settings.soundEnabled); Game.vm = new ViewManager(); Game.r1 = new RegionData(); Game.r2 = new RegionData(); Game.r3 = new RegionData(); new Thread(delegate() { bgload(); }).Start(); }
public void drawSprite(float x, float y, float width, float height, float angle,float px,float py, TextureRegion region) { float sx = width /( region.rectangle.Width); float sy= -height /( region.rectangle.Height); //y =- y; //py = -py; // height = -height; //TerVel.Main.spriteBatch.Draw(region.texhold.tex, new Vector2(x,y), region.rectangle, Color.White, angle * -0.0174533F, new Vector2(width/2+px,-height/2+py), new Vector2(sx, sy), SpriteEffects.None, 0); //Vector2 scale= new Vector2(sx,sy); if (sx < 0) { sx = sx * -1; Vector2 scale = new Vector2(sx, sy); Vector2 origin = new Vector2((width / 2 + px) / sx, -(height / 2 + py) / (sy)); Vector2 position = new Vector2(x, y); TerVel.Main.spriteBatch.Draw(region.texhold.tex, position, region.rectangle, Assets.color, angle * 0.0174533F, origin, scale, SpriteEffects.FlipHorizontally, 0); } else { Vector2 scale = new Vector2(sx, sy); Vector2 origin = new Vector2((width / 2 + px) / sx, -(height / 2 + py) / (sy)); Vector2 position = new Vector2(x, y); TerVel.Main.spriteBatch.Draw(region.texhold.tex, position, region.rectangle, Assets.color, angle * 0.0174533F, origin, scale, SpriteEffects.None, 0); } }
public FontExtension(Texture texture, int offsetX, int offsetY, int glyphsPerRow, int glyphWidth, int glyphHeight) { //super(texture, offsetX, offsetY, glyphsPerRow, glyphWidth, glyphHeight); this.texture = texture; this.glyphWidth = glyphWidth; this.glyphHeight = glyphHeight; int x = offsetX; int y = offsetY; for (int i = 0; i < 96; i++) { glyphs[i] = new TextureRegion(texture, x, y, glyphWidth, glyphHeight); x += glyphWidth; if (x == offsetX + glyphsPerRow * 50) { x = offsetX; y += 50; } } }
public void drawSprite(float x, float y, float width, float height, float angle, TextureRegion region) { drawSprite(x, y, width, height, angle, 0, 0, region); }
public void drawSprite(float x, float y, float width, float height, float angle, float px, float py, TextureRegion region) { float sx = width / (region.rectangle.Width); float sy = -height / (region.rectangle.Height); //y =- y; //py = -py; // height = -height; //TerVel.Main.spriteBatch.Draw(region.texhold.tex, new Vector2(x,y), region.rectangle, Color.White, angle * -0.0174533F, new Vector2(width/2+px,-height/2+py), new Vector2(sx, sy), SpriteEffects.None, 0); //Vector2 scale= new Vector2(sx,sy); if (sx < 0) { sx = sx * -1; Vector2 scale = new Vector2(sx, sy); Vector2 origin = new Vector2((width / 2 + px) / sx, -(height / 2 + py) / (sy)); Vector2 position = new Vector2(x, y); TerVel.Main.spriteBatch.Draw(region.texhold.tex, position, region.rectangle, Assets.color, angle * 0.0174533F, origin, scale, SpriteEffects.FlipHorizontally, 0); } else { Vector2 scale = new Vector2(sx, sy); Vector2 origin = new Vector2((width / 2 + px) / sx, -(height / 2 + py) / (sy)); Vector2 position = new Vector2(x, y); TerVel.Main.spriteBatch.Draw(region.texhold.tex, position, region.rectangle, Assets.color, angle * 0.0174533F, origin, scale, SpriteEffects.None, 0); } }
public static void bgload() { texcount = 0; texregcount = 0; fontcount = 0; loaderparser.loadindex("asset.items"); Settings.soundvolume = .7f; Settings.musicvolume = .3f; ////////////////////////////////////////////////////////////// textures = new Texture[TextureNames.Count]; textureregions = new TextureRegion[TextureRegionNames.size()]; sounds = new Sound[SoundNames.Count]; music = new Music[MusicNames.Count]; fonts = new FontExtension[2]; music[Settings.musicindex] = new Music(MusicNames[Settings.musicindex]); music[Settings.musicindex].setLooping(true); music[Settings.musicindex].setVolume(Settings.musicvolume); if (Settings.musicEnabled) { music[Settings.musicindex].play(); isMusicPlaying = true; } adjustvolume(Settings.musicvolume, 1); adjustvolume(Settings.soundvolume, 0); //load all textures reported by pack files///////////// int i = 0; while (i < TextureNames.Count) { textures[i] = new Texture(TextureNames[i]); i++; } Assets.loaderp = 60; i = 0; ///////////////////////////////Load fonts////////////////////////////////// while (i < 2) { string[] s = { "font1", "font2" }; int[] w = { 50, 50, 50, 50 }; int x = TexturRegionName.x[(TexturRegionName.texturegionname.IndexOf(s[i]))] + 9; int y = TexturRegionName.y[(TexturRegionName.texturegionname.IndexOf(s[i]))] + 11; fonts[i]=new FontExtension(textures[TextureNames.IndexOf(FontNames[0])],x,y,16,w[i],w[i+2]); i++; } i = 0; Assets.loaderp = 65; //////////////load all textures regions reported by pack files//////////////// while (i < TexturRegionName.texturename.Count) { int x, y, w, h; x = TexturRegionName.x[i]; y = TexturRegionName.y[i]; w = TexturRegionName.sizex[i]; h = TexturRegionName.sizey[i]; textureregions[i] = new TextureRegion(gettexture(TexturRegionName.texturename[i]), x, y, w, h); i++; Assets.loaderp = 65 + 30 * (i * 100 / TexturRegionName.texturename.Count) / 100; } i = 0; Assets.loaderp = 95; ///////////////load all sounds reported by pack files///////////////////////// sounds[0] = new Sound(SoundNames[0]); sounds[1] = new Sound(SoundNames[2]); sounds[2] = new Sound(SoundNames[1]); /*/ while(i<SoundNames.size()) { sounds[i] = new Sound(SoundNames(i)); i++; } //*/ Assets.loaderp = 100; //////////////////////////////////////////Load all Patterns///////////////////////////// }
public static void bgload() { texcount = 0; texregcount = 0; fontcount = 0; loaderparser.loadindex("asset.items"); Settings.soundvolume = .7f; Settings.musicvolume = .3f; ////////////////////////////////////////////////////////////// textures = new Texture[TextureNames.Count]; textureregions = new TextureRegion[TextureRegionNames.size()]; sounds = new Sound[SoundNames.Count]; music = new Music[MusicNames.Count]; fonts = new FontExtension[2]; music[Settings.musicindex] = new Music(MusicNames[Settings.musicindex]); music[Settings.musicindex].setLooping(true); music[Settings.musicindex].setVolume(Settings.musicvolume); if (Settings.musicEnabled) { music[Settings.musicindex].play(); isMusicPlaying = true; } adjustvolume(Settings.musicvolume, 1); adjustvolume(Settings.soundvolume, 0); //load all textures reported by pack files///////////// int i = 0; while (i < TextureNames.Count) { textures[i] = new Texture(TextureNames[i]); i++; } Assets.loaderp = 60; i = 0; ///////////////////////////////Load fonts////////////////////////////////// while (i < 2) { string[] s = { "font1", "font2" }; int[] w = { 50, 50, 50, 50 }; int x = TexturRegionName.x[(TexturRegionName.texturegionname.IndexOf(s[i]))] + 9; int y = TexturRegionName.y[(TexturRegionName.texturegionname.IndexOf(s[i]))] + 11; fonts[i] = new FontExtension(textures[TextureNames.IndexOf(FontNames[0])], x, y, 16, w[i], w[i + 2]); i++; } i = 0; Assets.loaderp = 65; //////////////load all textures regions reported by pack files//////////////// while (i < TexturRegionName.texturename.Count) { int x, y, w, h; x = TexturRegionName.x[i]; y = TexturRegionName.y[i]; w = TexturRegionName.sizex[i]; h = TexturRegionName.sizey[i]; textureregions[i] = new TextureRegion(gettexture(TexturRegionName.texturename[i]), x, y, w, h); i++; Assets.loaderp = 65 + 30 * (i * 100 / TexturRegionName.texturename.Count) / 100; } i = 0; Assets.loaderp = 95; ///////////////load all sounds reported by pack files///////////////////////// sounds[0] = new Sound(SoundNames[0]); sounds[1] = new Sound(SoundNames[2]); sounds[2] = new Sound(SoundNames[1]); /*/ * while(i<SoundNames.size()) * * { sounds[i] = new Sound(SoundNames(i)); * i++; * } * //*/ Assets.loaderp = 100; //////////////////////////////////////////Load all Patterns///////////////////////////// }