Skip to content

Commit

Permalink
Main Menu Background 6/n
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityayadav17 committed Oct 2, 2023
1 parent a88ea92 commit 0a3aa79
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,22 @@ public void changed(ChangeEvent changeEvent, Actor actor) {
}
});

// Proportional padding values based on original screen or background dimensions
float originalScreenWidth = 1920; // Replace with the original width if different
float originalScreenHeight = 1080; // Replace with the original height if different

float padTopStartBtn = 260f / originalScreenHeight * Gdx.graphics.getHeight();
float padTopOtherBtns = 15f / originalScreenHeight * Gdx.graphics.getHeight();

table.add(title);
table1.row();
table1.add(startBtn).padTop(260f);
table1.add(startBtn).padTop(padTopStartBtn);
table1.row();
table1.add(helpBtn).padTop(15f);
table1.add(helpBtn).padTop(padTopOtherBtns);
table1.row();
table1.add(settingsBtn).padTop(15f);
table1.add(settingsBtn).padTop(padTopOtherBtns);
table1.row();
table1.add(exitBtn).padTop(15f);
table1.add(exitBtn).padTop(padTopOtherBtns);

stage.addActor(table);
stage.addActor(table1);
Expand Down
92 changes: 30 additions & 62 deletions source/core/src/main/com/csse3200/game/screens/MainMenuScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ public class MainMenuScreen extends ScreenAdapter {
private int MM_Planet3_frameWidth;
private int MM_Planet3_frameHeight;

// private int MM_MonitorFace1_frameWidth;
// private int MM_MonitorFace1_frameHeight;
private static final String[] mainMenuTextures = {"images/background/main_menu/main_menu_bg.png"};

public MainMenuScreen(GdxGame game) {
Expand Down Expand Up @@ -98,86 +96,73 @@ public void render(float delta) {
elapsedTime += delta;

// MM_Star1
// Fixed offset relative to the background texture
float MM_Star1_fixedOffsetX = 830;
float MM_Star1_fixedOffsetY = 650;
// Determine the proportional offset of the MM_Star1 sprite
float MM_Star1_proportionalOffsetX = 830f / backgroundTexture.getWidth();
float MM_Star1_proportionalOffsetY = 650f / backgroundTexture.getHeight();
// Calculate the scaling factor based on how the background is stretched to fit the screen
float scaleX = screenWidth / backgroundTexture.getWidth();
float scaleY = screenHeight / backgroundTexture.getHeight();
// Scale the fixed offset
float MM_Star1_spriteX = MM_Star1_fixedOffsetX * scaleX;
float MM_Star1_spriteY = MM_Star1_fixedOffsetY * scaleY;
// Calculate the position of the MM_Star1 sprite on the screen
float MM_Star1_spriteX = MM_Star1_proportionalOffsetX * screenWidth;
float MM_Star1_spriteY = MM_Star1_proportionalOffsetY * screenHeight;
// Size adjustments
float MM_Star1_ScaleFactor = 0.3f;
float MM_Star1_Width = MM_Star1_frameWidth * MM_Star1_ScaleFactor;
float MM_Star1_Height = MM_Star1_frameHeight * MM_Star1_ScaleFactor;
batch.draw(MM_Star1_animation.getKeyFrame(elapsedTime, true), MM_Star1_spriteX, MM_Star1_spriteY, MM_Star1_Width, MM_Star1_Height);

// MM_Galaxy1
// Fixed offset relative to the background texture
float MM_Galaxy1_fixedOffsetX = 2000;
float MM_Galaxy1_fixedOffsetY = 1075;
// Scale the fixed offset
float MM_Galaxy1_spriteX = MM_Galaxy1_fixedOffsetX * scaleX;
float MM_Galaxy1_spriteY = MM_Galaxy1_fixedOffsetY * scaleY;
// Determine the proportional offset of the MM_Star1 sprite
float MM_Galaxy1_proportionalOffsetX = 2000f / backgroundTexture.getWidth();
float MM_Galaxy1_proportionalOffsetY = 1075f / backgroundTexture.getHeight();
// Calculate the position of the MM_Star1 sprite on the screen
float MM_Galaxy1_spriteX = MM_Galaxy1_proportionalOffsetX * screenWidth;
float MM_Galaxy1_spriteY = MM_Galaxy1_proportionalOffsetY * screenHeight;
// Size adjustments
float MM_Galaxy1_ScaleFactor = 0.95f;
float MM_Galaxy1_Width = MM_Galaxy1_frameWidth * MM_Galaxy1_ScaleFactor;
float MM_Galaxy1_Height = MM_Galaxy1_frameHeight * MM_Galaxy1_ScaleFactor;
batch.draw(MM_Galaxy1_animation.getKeyFrame(elapsedTime, true), MM_Galaxy1_spriteX, MM_Galaxy1_spriteY, MM_Galaxy1_Width, MM_Galaxy1_Height);

// MM_Planet1
// Fixed offset relative to the background texture
float MM_Planet1_fixedOffsetX = 1630;
float MM_Planet1_fixedOffsetY = 800;
// Scale the fixed offset
float MM_Planet1_spriteX = MM_Planet1_fixedOffsetX * scaleX;
float MM_Planet1_spriteY = MM_Planet1_fixedOffsetY * scaleY;
// Determine the proportional offset of the MM_Star1 sprite
float MM_Planet1_proportionalOffsetX = 1630f / backgroundTexture.getWidth();
float MM_Planet1_proportionalOffsetY = 800f / backgroundTexture.getHeight();
// Calculate the position of the MM_Star1 sprite on the screen
float MM_Planet1_spriteX = MM_Planet1_proportionalOffsetX * screenWidth;
float MM_Planet1_spriteY = MM_Planet1_proportionalOffsetY * screenHeight;
// Size adjustments
float MM_Planet1_ScaleFactor = 0.5f;
float MM_Planet1_Width = MM_Planet1_frameWidth * MM_Planet1_ScaleFactor;
float MM_Planet1_Height = MM_Planet1_frameHeight * MM_Planet1_ScaleFactor;
batch.draw(MM_Planet1_animation.getKeyFrame(elapsedTime, true), MM_Planet1_spriteX, MM_Planet1_spriteY, MM_Planet1_Width, MM_Planet1_Height);

// MM_Planet2
// Fixed offset relative to the background texture
float MM_Planet2_fixedOffsetX = 1290;
float MM_Planet2_fixedOffsetY = 1200;
// Scale the fixed offset
float MM_Planet2_spriteX = MM_Planet2_fixedOffsetX * scaleX;
float MM_Planet2_spriteY = MM_Planet2_fixedOffsetY * scaleY;
// Determine the proportional offset of the MM_Star1 sprite
float MM_Planet2_proportionalOffsetX = 1290f / backgroundTexture.getWidth();
float MM_Planet2_proportionalOffsetY = 1200f / backgroundTexture.getHeight();
// Calculate the position of the MM_Star1 sprite on the screen
float MM_Planet2_spriteX = MM_Planet2_proportionalOffsetX * screenWidth;
float MM_Planet2_spriteY = MM_Planet2_proportionalOffsetY * screenHeight;
// Size adjustments
float MM_Planet2_ScaleFactor = 0.7f;
float MM_Planet2_Width = MM_Planet2_frameWidth * MM_Planet2_ScaleFactor;
float MM_Planet2_Height = MM_Planet2_frameHeight * MM_Planet2_ScaleFactor;
batch.draw(MM_Planet2_animation.getKeyFrame(elapsedTime, true), MM_Planet2_spriteX, MM_Planet2_spriteY, MM_Planet2_Width, MM_Planet2_Height);

// MM_Planet3
// Fixed offset relative to the background texture
float MM_Planet3_fixedOffsetX = 420;
float MM_Planet3_fixedOffsetY = 990;
// Scale the fixed offset
float MM_Planet3_spriteX = MM_Planet3_fixedOffsetX * scaleX;
float MM_Planet3_spriteY = MM_Planet3_fixedOffsetY * scaleY;
// Determine the proportional offset of the MM_Star1 sprite
float MM_Planet3_proportionalOffsetX = 420f / backgroundTexture.getWidth();
float MM_Planet3_proportionalOffsetY = 990f / backgroundTexture.getHeight();
// Calculate the position of the MM_Star1 sprite on the screen
float MM_Planet3_spriteX = MM_Planet3_proportionalOffsetX * screenWidth;
float MM_Planet3_spriteY = MM_Planet3_proportionalOffsetY * screenHeight;
// Size adjustments
float MM_Planet3_ScaleFactor = 0.65f;
float MM_Planet3_Width = MM_Planet3_frameWidth * MM_Planet3_ScaleFactor;
float MM_Planet3_Height = MM_Planet3_frameHeight * MM_Planet3_ScaleFactor;
batch.draw(MM_Planet3_animation.getKeyFrame(elapsedTime, true), MM_Planet3_spriteX, MM_Planet3_spriteY, MM_Planet3_Width, MM_Planet3_Height);

// // MM_MonitorFace1
// // Fixed offset relative to the background texture
// float MM_MonitorFace1_fixedOffsetX = 1850;
// float MM_MonitorFace1_fixedOffsetY = 350;
// // Scale the fixed offset
// float MM_MonitorFace1_spriteX = MM_MonitorFace1_fixedOffsetX * scaleX;
// float MM_MonitorFace1_spriteY = MM_MonitorFace1_fixedOffsetY * scaleY;
// // Size adjustments
// float MM_MonitorFace1_ScaleFactor = 3.5f;
// float MM_MonitorFace1_Width = MM_MonitorFace1_frameWidth * MM_MonitorFace1_ScaleFactor;
// float MM_MonitorFace1_Height = MM_MonitorFace1_frameHeight * MM_MonitorFace1_ScaleFactor;
// batch.draw(MM_MonitorFace1_animation.getKeyFrame(elapsedTime, true), MM_MonitorFace1_spriteX, MM_MonitorFace1_spriteY, MM_MonitorFace1_Width, MM_MonitorFace1_Height);

batch.end();
}

Expand Down Expand Up @@ -300,23 +285,6 @@ private void loadAssets() {

MM_Planet3_animation = new Animation<>(0.17f, MM_Planet3_animationFrames);


// // MM_MonitorFace1
// MM_MonitorFace1_Texture = new Texture(Gdx.files.internal("images/background/main_menu/MM_Objects/MM_MonitorFace1.png"));

// int MM_MonitorFace1_totalColumns=4;
// MM_MonitorFace1_frameWidth = MM_MonitorFace1_Texture.getWidth() / MM_MonitorFace1_totalColumns; // totalColumns = no. of columns in MM_Star1 sprite sheet
// int MM_MonitorFace1_totalRows=1;
// MM_MonitorFace1_frameHeight = MM_MonitorFace1_Texture.getHeight() / MM_MonitorFace1_totalRows; // totalRows = no. of rows in MM_Star1 sprite sheet
//
// TextureRegion[][] MM_MonitorFace1_Frames = TextureRegion.split(MM_MonitorFace1_Texture, MM_MonitorFace1_frameWidth, MM_MonitorFace1_frameHeight);
//
// TextureRegion[] MM_MonitorFace1_animationFrames = new TextureRegion[MM_MonitorFace1_totalColumns];
//
// System.arraycopy(MM_MonitorFace1_Frames[0], 0, MM_MonitorFace1_animationFrames, 0, MM_MonitorFace1_totalColumns);
//
// MM_MonitorFace1_animation = new Animation<>(0.1f, MM_MonitorFace1_animationFrames);

ServiceLocator.getResourceService().loadAll();
}

Expand Down

0 comments on commit 0a3aa79

Please sign in to comment.