Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags
(1 edit)

Day 7:

Progress :)

  • I remove control up and control down. Too many difficult.
  • I paint a background of stars and it scroll when you move spaceship

I found this code (very usefull) :)

public static Texture texture_static_fieldStars;
texture_static_fieldStars = new Texture("fieldstars.jpg");
texture_static_fieldStars.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
private Sprite fieldStars;
fieldStars = new Sprite(texture_static_fieldStars);


private void drawFieldStars(float delta){

sprite.disableBlending();

if (spaceShip.getState()==SpaceShip.Keys.TURN_RIGHT)
scrollTimer.x += 0.05f*Gdx.graphics.getDeltaTime();
if (spaceShip.getState()==SpaceShip.Keys.TURN_LEFT)
scrollTimer.x -= 0.05f*Gdx.graphics.getDeltaTime();
if (spaceShip.getState()==SpaceShip.Keys.UP)
scrollTimer.y -= 0.05f*Gdx.graphics.getDeltaTime();
if (spaceShip.getState()==SpaceShip.Keys.DOWN)
scrollTimer.y += 0.05f*Gdx.graphics.getDeltaTime();

scrollTimer.add(0.00001f,0.00001f);

if(scrollTimer.x>1.0f)
scrollTimer.x = 0.0f;
if(scrollTimer.y>1.0f)
scrollTimer.y = 0.0f;

fieldStars.setU(scrollTimer.x);
fieldStars.setU2(scrollTimer.x+1);
fieldStars.setV(scrollTimer.y);
fieldStars.setV2(scrollTimer.y+1);

fieldStars.draw(sprite);

sprite.enableBlending();


}


  • I DRAW A RADAR to show where is Ufos and Earth position.

It was very hard to face the 3D coordinates of the UFOS and Earth to 2D coordinates of the radar.
Basically what I do is to calculate the distance to the 3D Spaceship (displayed in the center of the radar) and applying the rule of three step-radar coordinates.
After I apply the rotation angle of the ship to rotate the elements of the radar when I turn the ship.

Code:

float radar_distance_detect=World3D.SOLARSYSTEM_SIZE;

// DRAW UFOS IN RADAR
for (Ufo ufo : world3d.getUfos()){
temp1.set(ufo.getPosition());
temp2.set(spaceShip.getPosition());

float distance = temp1.dst(temp2);
temp1.sub(temp2); // SUB Ufos position from SpaceShip position

if (distance<radar_distance_detect){
float translateValue = (Radar.size_radar.width/2)/radar_distance_detect;
temp1.set(temp1.x*translateValue,0,-temp1.z*translateValue);
temp1.rotate(spaceShip.getAngle_rot().y,0,1,0);

float pointYradarcentral = camera2D.viewportHeight-(Radar.size_radar.height/2);
float pointXradarcentral = (Radar.size_radar.width/2);
temp1.z = pointYradarcentral - temp1.z;
temp1.x = pointXradarcentral - temp1.x;

sprite.draw(LoadAssets.texture_static_ufo,temp1.x-4,temp1.z-4,10,10);

}

}

I do not know why not come out exactly the right point and I had to subtract 4 to its location on the radar ....


  • Ufos creates outside Solar System. Only 5. If you kill them, I create another 5 until 20. If you kill all, YOU WIN.
  • You can minimize radar when touch it with mouse.
  • I add keyboard control (arrow left-arrow right-arrow up (accelerate)-arrow down (brake) )

Countdown started :)


A image progress: