Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rushan-zagidullin committed Apr 23, 2018
0 parents commit f2d8e77
Show file tree
Hide file tree
Showing 29 changed files with 831 additions and 0 deletions.
125 changes: 125 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
## Java

*.class
*.war
*.ear
hs_err_pid*

## Robovm
/ios/robovm-build/

## GWT
/html/war/
/html/gwt-unitCache/
.apt_generated/
.gwt/
gwt-unitCache/
www-test/
.gwt-tmp/

## Android Studio and Intellij and Android in general
/android/libs/armeabi/
/android/libs/armeabi-v7a/
/android/libs/arm64-v8a/
/android/libs/x86/
/android/libs/x86_64/
/android/gen/
.idea/
*.ipr
*.iws
*.iml
/android/out/
com_crashlytics_export_strings.xml

## Eclipse

.classpath
.project
.metadata/
/android/bin/
/core/bin/
/desktop/bin/
/html/bin/
/ios/bin/
/ios-moe/bin/
*.tmp
*.bak
*.swp
*~.nib
.settings/
.loadpath
.externalToolBuilders/
*.launch

## NetBeans

/nbproject/private/
/android/nbproject/private/
/core/nbproject/private/
/desktop/nbproject/private/
/html/nbproject/private/
/ios/nbproject/private/
/ios-moe/nbproject/private/

/build/
/android/build/
/core/build/
/desktop/build/
/html/build/
/ios/build/
/ios-moe/build/

/nbbuild/
/android/nbbuild/
/core/nbbuild/
/desktop/nbbuild/
/html/nbbuild/
/ios/nbbuild/
/ios-moe/nbbuild/

/dist/
/android/dist/
/core/dist/
/desktop/dist/
/html/dist/
/ios/dist/
/ios-moe/dist/

/nbdist/
/android/nbdist/
/core/nbdist/
/desktop/nbdist/
/html/nbdist/
/ios/nbdist/
/ios-moe/nbdist/

nbactions.xml
nb-configuration.xml

## Gradle

/local.properties
.gradle/
gradle-app.setting
/build/
/android/build/
/core/build/
/desktop/build/
/html/build/
/ios/build/
/ios-moe/build/

## OS Specific
.DS_Store
Thumbs.db

## iOS
/ios/xcode/*.xcodeproj/*
!/ios/xcode/*.xcodeproj/xcshareddata
!/ios/xcode/*.xcodeproj/project.pbxproj
/ios/xcode/native/

/ios-moe/xcode/*.xcodeproj/*
!/ios-moe/xcode/*.xcodeproj/xcshareddata
!/ios-moe/xcode/*.xcodeproj/project.pbxproj
/ios-moe/xcode/native/
64 changes: 64 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
buildscript {


repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
jcenter()
}
dependencies {


}
}

allprojects {
apply plugin: "eclipse"
apply plugin: "idea"

version = '1.0'
ext {
appName = "FlappyDemo"
gdxVersion = '1.9.8'
roboVMVersion = '2.3.3'
box2DLightsVersion = '1.4'
ashleyVersion = '1.7.0'
aiVersion = '1.8.0'
}

repositories {
mavenLocal()
mavenCentral()
maven { url "https://oss.sonatype.org/content/repositories/snapshots/" }
maven { url "https://oss.sonatype.org/content/repositories/releases/" }
}
}

project(":desktop") {
apply plugin: "java"


dependencies {
compile project(":core")
compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
compile "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"

}
}

project(":core") {
apply plugin: "java"


dependencies {
compile "com.badlogicgames.gdx:gdx:$gdxVersion"
compile "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"

}
}

tasks.eclipse.doLast {
delete ".project"
}
Binary file added core/assets/badlogic.jpg
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 core/assets/bg.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 core/assets/bird.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 core/assets/birdanimation.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 core/assets/bottomtube.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 core/assets/gameover.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 core/assets/ground.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 core/assets/music.mp3
Binary file not shown.
Binary file added core/assets/playbtn.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 core/assets/sfx_wing.ogg
Binary file not shown.
Binary file added core/assets/toptube.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apply plugin: "java"

sourceCompatibility = 1.6
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

sourceSets.main.java.srcDirs = [ "src/" ]


eclipse.project {
name = appName + "-core"
}
41 changes: 41 additions & 0 deletions core/src/com/rushan/game/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.rushan.game;

import com.badlogic.gdx.ApplicationAdapter;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.rushan.game.states.GameStateManager;
import com.rushan.game.states.MenuState;

public class Main extends ApplicationAdapter {
public static final int WIDTH = 480;
public static final int HEIGHT = 800;

public static final String TITLE = "flappy bird";
private GameStateManager gameStateManager;
private SpriteBatch spriteBatch;
Texture img;

@Override
public void create () {
spriteBatch = new SpriteBatch();
gameStateManager = new GameStateManager();
img = new Texture("badlogic.jpg");
gameStateManager.push(new MenuState(gameStateManager));
}

@Override
public void render () {
Gdx.gl.glClearColor(1, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
gameStateManager.update(Gdx.graphics.getDeltaTime());
gameStateManager.render(spriteBatch);
}

@Override
public void dispose () {
spriteBatch.dispose();
img.dispose();
}
}
43 changes: 43 additions & 0 deletions core/src/com/rushan/game/sprites/Bird.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.rushan.game.sprites;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector3;

/**
* @author rushan
* @since 23.04.2018
*/
public class Bird {
private static final int GRAVITY = - 15;
private Vector3 position;
private Vector3 velocity;
private Texture bird;

public Bird(int x, int y) {
position = new Vector3(x, y, 0);
velocity = new Vector3(0, 0, 0);
bird = new Texture("bird.png");
}

public void update(float delta) {
if (position.y > 0) {
velocity.add(0, GRAVITY * delta, 0);
}
position.add(0, velocity.y, 0);
if (position.y < 0) {
position.y = 0;
}
}

public void jump() {
velocity.y = 15;
}

public Vector3 getPosition() {
return position;
}

public Texture getBird() {
return bird;
}
}
45 changes: 45 additions & 0 deletions core/src/com/rushan/game/sprites/Tube.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.rushan.game.sprites;

import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.math.Vector2;

import java.util.Random;

/**
* @author rushan
* @since 23.04.2018
*/
public class Tube {
private static final int FLUCTUATION = 130;
private static final int TUBE_GAP = 100;
private static final int LOWEST_OPENING = 120;
private Texture topTube;
private Texture bottomTube;
private Vector2 posTopTube;
private Vector2 posBottomTube;
private Random random;

public Tube(float x) {
topTube = new Texture("toptube.png");
bottomTube = new Texture("bottomtube.png");
random = new Random();
posTopTube = new Vector2(x, random.nextInt(FLUCTUATION) + TUBE_GAP + LOWEST_OPENING);
posBottomTube = new Vector2(x, posTopTube.y - TUBE_GAP - bottomTube.getHeight());
}

public Texture getTopTube() {
return topTube;
}

public Texture getBottomTube() {
return bottomTube;
}

public Vector2 getPosTopTube() {
return posTopTube;
}

public Vector2 getPosBottomTube() {
return posBottomTube;
}
}
34 changes: 34 additions & 0 deletions core/src/com/rushan/game/states/GameStateManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package com.rushan.game.states;

import com.badlogic.gdx.graphics.g2d.SpriteBatch;

import java.util.Stack;

/**
* @author rushan
* @since 16.04.2018
*/
public class GameStateManager {
private Stack<State> states = new Stack<>();

public void push(State state) {
states.push(state);
}

public void pop() {
states.pop();
}

public void set(State state) {
states.pop();
states.push(state);
}

public void update(float delta) {
states.peek().update(delta);
}

public void render(SpriteBatch spriteBatch) {
states.peek().render(spriteBatch);
}
}
Loading

0 comments on commit f2d8e77

Please sign in to comment.