Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

マッチョ星雲を追加 #273

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added resource/mini_game/macho_game/_arm_fore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resource/mini_game/macho_game/_arm_upper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resource/mini_game/macho_game/arm_fore.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resource/mini_game/macho_game/arm_upper.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added resource/mini_game/macho_game/staricon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
package net.trpfrog.medipro_game.mini_game.macho_game;

import net.trpfrog.medipro_game.MainView;
import net.trpfrog.medipro_game.pause.EscapeToPause;
import net.trpfrog.medipro_game.scene.GameController;

import javax.swing.*;
import java.awt.Point;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class MachoController extends GameController implements MouseListener, MouseMotionListener, KeyListener
{
private MachoModel model;
private MachoView view;
private Point clickPoint;

public MachoController( MachoModel model, MachoView view )
{
super(model, view);
this.model = model;
this.view = view;
clickPoint = new Point();

// view に listener を add する
view.addKeyListener( new EscapeToPause() );
view.addKeyListener( this );
view.addMouseMotionListener( this );
view.addMouseListener( this );
}

@Override
public void mousePressed( MouseEvent e )
{
clickPoint = e.getPoint();
model.getForeArm().memorizeDegree();
// System.out.println( clickPoint );
}

@Override
public void mouseEntered( MouseEvent e ) {}

@Override
public void mouseReleased( MouseEvent e ) {}

@Override
public void mouseClicked( MouseEvent e ) {}

@Override
public void mouseExited( MouseEvent e ) {}


@Override
public void mouseDragged( MouseEvent e )
{
// model.getForeArm().setAngleDegrees( (double)( ( e.getPoint().x - clickPoint.x ) ) );
model.getForeArm().setAngleDegrees( (double)( ( e.getPoint().x - clickPoint.x ) / 256 ) );
}

@Override
public void mouseMoved( MouseEvent e ) {}

@Override
public void keyTyped( KeyEvent e ) {}

@Override
public void keyPressed( KeyEvent e ) {}

@Override
public void keyReleased( KeyEvent e ) {}

@Override
public void suspend() {}

@Override
public void resume() {}
}
114 changes: 114 additions & 0 deletions src/net/trpfrog/medipro_game/mini_game/macho_game/MachoModel.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
package net.trpfrog.medipro_game.mini_game.macho_game;

import net.trpfrog.medipro_game.mini_game.macho_game.symbols.Background;
import net.trpfrog.medipro_game.mini_game.macho_game.symbols.Counter;
import net.trpfrog.medipro_game.mini_game.macho_game.symbols.UpperArm;
import net.trpfrog.medipro_game.mini_game.macho_game.symbols.ForeArm;
import net.trpfrog.medipro_game.mini_game.macho_game.symbols.MuscleGauge;
import net.trpfrog.medipro_game.dialog_background.DialogBackgroundScene;
import net.trpfrog.medipro_game.mini_game.GameOverWindow;
import net.trpfrog.medipro_game.SceneManager;
import net.trpfrog.medipro_game.scene.GameModel;
import net.trpfrog.medipro_game.scene.GameView;
import net.trpfrog.medipro_game.player.Medal;
import net.trpfrog.medipro_game.player.MedalWindow;

import net.trpfrog.medipro_game.mini_game.macho_game.util.GameTimer;

import javax.swing.*;
import java.awt.*;


public class MachoModel extends GameModel
{
private Background background;
private UpperArm upperArm;
private ForeArm foreArm;
private Counter counter;
private MuscleGauge muscleGauge;
private GameTimer gameTimer = new GameTimer( 10 * 1000 );

public MachoModel() {
background = new Background();
upperArm = new UpperArm();
foreArm = new ForeArm();
counter = new Counter();
muscleGauge = new MuscleGauge();
}

public UpperArm getUpperArm()
{
return upperArm;
}

public ForeArm getForeArm()
{
return foreArm;
}

public Background getBackground()
{
return background;
}

public MuscleGauge getMuscleGauge()
{
return muscleGauge;
}

public Counter getCounter()
{
return counter;
}

public GameTimer getGameTimer()
{
return gameTimer;
}

public void loop()
{
// タイマー監視
if( getGameTimer().isLimit() ) {
if( !getForeArm().isReleased ) {
// getCounter().setCount( "0" );
getForeArm().isReleased = true;
endGame();
}
}
getForeArm().releaseObserver();

getCounter().setCount( getGameTimer().getRemainingTime() );

// マッスルゲージ更新
double mg = getForeArm().getAngleDegrees();
getMuscleGauge().setGaugePercentage( 100.0 / 150.0 * mg );
}

public void endGame()
{
var window = new GameOverWindow( "YOUR MUSCLE",
getMuscleGauge().getHighestPercent(),
new Color( 0x88E01D00, true )
);

var scene = new DialogBackgroundScene( window, false );

SceneManager.getInstance().push( scene );
if( getMuscleGauge().getHighestPercent() < 100 ) return;
MedalWindow.pushMedalWindow( new Medal(
"KIN NIKU MUSCLE", new MachoScene().getStarImage() )
);
}


@Override
public void suspend() {
gameTimer.stop();
}

@Override
public void resume() {
gameTimer.start();
}
}
47 changes: 47 additions & 0 deletions src/net/trpfrog/medipro_game/mini_game/macho_game/MachoScene.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
package net.trpfrog.medipro_game.mini_game.macho_game;

import net.trpfrog.medipro_game.SceneManager;
import net.trpfrog.medipro_game.mini_game.MiniGameScene;

import java.nio.file.Paths;

public class MachoScene extends MiniGameScene {
public MachoScene() {
setModel(new MachoModel());
setView(new MachoView((MachoModel)getModel()));
setController(new MachoController((MachoModel)getModel(), (MachoView)getView()));

setGameTitle("マッチョ星雲");
setCreatorName("Created by キン肉一世");

setGameDescription(
"マッチョの世界へようこそ!"
);

setHowToPlay(
"  __",
"  / )))   _",
"`/ イ~   (((ヽ",
"(  ノ      ̄Y\",
"| (\ ∧_∧ | )",
"ヽ ヽ`(´・ω・)/ノ/",
" \ | ⌒Y⌒ / /",
"  |ヽ  |  ノ/",
"  \トー仝ーイ",
"   | ミ土彡/",
"   )   |",
"   /  _  \",
"  /  / \  ヽ",
"  /  /   ヽ |"
);

setStarImage(Paths.get(".","resource","mini_game","macho_game","staricon.png"));

makeDescriptionDialog();
}

// テスト用にこういうのがあると便利
public static void main(String[] args) {
SceneManager.getInstance().push(new MachoScene());
}
}
58 changes: 58 additions & 0 deletions src/net/trpfrog/medipro_game/mini_game/macho_game/MachoView.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package net.trpfrog.medipro_game.mini_game.macho_game;

import net.trpfrog.medipro_game.scene.GameModel;
import net.trpfrog.medipro_game.scene.GameView;


import javax.swing.*;
import java.awt.*;

public class MachoView extends GameView
{
private MachoModel model;
private Timer paintTimer = new Timer( 10, g -> repaint() );

public MachoView( MachoModel model )
{
super( model );
this.model = model;
setBackground( new Color( 0x111111 ) );
}


@Override
protected void paintComponent( Graphics g )
{
super.paintComponent( g );

// 背景を描画
model.getBackground().getDrawer().draw( (Graphics2D)g );

// 腕を描画
model.getUpperArm().getDrawer().draw( (Graphics2D)g );
model.getForeArm().getDrawer().draw( (Graphics2D)g );

// マッスルゲージを描画
model.getMuscleGauge().getDrawer().draw( (Graphics2D)g );

// カウンターを描画
model.getCounter().getDrawer().draw( (Graphics2D)g );

model.loop();

}


// paint用のタイマーを制御
@Override
public void suspend()
{
// paintTimer.stop();
}

@Override
public void resume()
{
paintTimer.start();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.trpfrog.medipro_game.mini_game.macho_game.symbols;

import net.trpfrog.medipro_game.Drawable;
import net.trpfrog.medipro_game.MainView;
import net.trpfrog.medipro_game.symbol.Symbol;

import java.awt.*;

public class Background extends Symbol implements Drawable {

public Background() {
MainView mv = MainView.getInstance();
setLocation(mv.getWidth()/2.0, mv.getHeight()/2.0);
setDrawer(this);
}

@Override
public void draw(Graphics2D g) {
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package net.trpfrog.medipro_game.mini_game.macho_game.symbols;

import net.trpfrog.medipro_game.Drawable;
import net.trpfrog.medipro_game.MainView;
import net.trpfrog.medipro_game.Suspendable;
import net.trpfrog.medipro_game.symbol.Symbol;

import net.trpfrog.medipro_game.mini_game.macho_game.util.GameTimer;

import javax.swing.*;
import java.awt.*;

public class Counter extends Symbol implements Drawable
{
private String count = "";

public Counter()
{
// 初期位置の設定
setLocation( 512, 512 );

// Drawableを乗せる
setDrawer( this );
}

public void setCount( long l )
{
count = Long.toString( l );
}

@Override
public void draw( Graphics2D g )
{
var mv = MainView.getInstance();

g.setColor( Color.WHITE );
g.setFont( new Font( g.getFont().getName(), g.getFont().getStyle(), 100 ) );
g.translate( ( mv.getWidth() / 2 ) - ( g.getFontMetrics().stringWidth( count ) / 2 ) , g.getFont().getSize() );
g.drawString( count, 0, 0 );
}
}
Loading