Skip to content
Snippets Groups Projects
Commit d17927e1 authored by Sixten Müller's avatar Sixten Müller
Browse files

Merge branch '5-set-up-firebase' into 'main'

Resolve "Set up Firebase"

Closes #5

See merge request !6
parents e4360344 31f1473a
No related branches found
No related tags found
1 merge request!6Resolve "Set up Firebase"
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<activity <activity
android:name="com.wordbattle.game.AndroidLauncher" android:name="com.wordbattle.game.AndroidLauncher"
android:label="@string/app_name" android:label="@string/app_name"
android:screenOrientation="landscape" android:screenOrientation="portrait"
android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout" android:configChanges="keyboard|keyboardHidden|navigation|orientation|screenSize|screenLayout"
android:exported="true"> android:exported="true">
<intent-filter> <intent-filter>
......
...@@ -21,7 +21,7 @@ android { ...@@ -21,7 +21,7 @@ android {
} }
defaultConfig { defaultConfig {
applicationId "com.wordbattle.game" applicationId "com.wordbattle.game"
minSdkVersion 14 minSdkVersion 19
targetSdkVersion 34 targetSdkVersion 34
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
......
package com.wordbattle.game;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.wordbattle.game.network.FirebaseInterface;
public class AndroidInterfaceClass implements FirebaseInterface {
FirebaseDatabase database;
DatabaseReference myRef;
public AndroidInterfaceClass() {
database = FirebaseDatabase.getInstance("https://wordbattle-96156-default-rtdb.europe-west1.firebasedatabase.app");
myRef = database.getReference("message");
myRef.setValue("HelloWorld");
}
@Override
public void SomeFunction() {
System.out.println("Something works");
}
}
package com.wordbattle.game; package com.wordbattle.game;
import android.os.Bundle; import android.os.Bundle;
import android.util.Log;
import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
import com.google.firebase.FirebaseApp;
import com.wordbattle.game.WordBattle; import com.wordbattle.game.WordBattle;
public class AndroidLauncher extends AndroidApplication { public class AndroidLauncher extends AndroidApplication {
@Override @Override
protected void onCreate (Bundle savedInstanceState) { protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
Log.d("AndroidLauncher", "onCreate is called"); // Add this line for logging
FirebaseApp.initializeApp(this);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
initialize(new WordBattle(), config); initialize(new WordBattle(new AndroidInterfaceClass()), config);
} }
} }
...@@ -7,7 +7,12 @@ buildscript { ...@@ -7,7 +7,12 @@ buildscript {
google() google()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:8.2.1' classpath 'com.android.tools.build:gradle:8.1.4'
classpath 'com.google.gms:google-services:4.4.1'
} }
} }
...@@ -45,7 +50,7 @@ project(":desktop") { ...@@ -45,7 +50,7 @@ project(":desktop") {
api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion" api "com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion"
api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" api "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop" api "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"
api "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop" implementation "com.badlogicgames.gdx:gdx-freetype-platform:$libGDXVersion:natives-desktop"
} }
} }
...@@ -66,8 +71,27 @@ project(":android") { ...@@ -66,8 +71,27 @@ project(":android") {
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64" natives "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" // Import the Firebase BoM
implementation platform('com.google.firebase:firebase-bom:32.8.0')
implementation 'com.google.firebase:firebase-database'
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86"
natives "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"
// TODO: Add the dependencies for Firebase products you want to use
// When using the BoM, don't specify versions in Firebase dependencies
implementation 'com.google.firebase:firebase-analytics'
} }
apply plugin: 'com.google.gms.google-services'
} }
project(":core") { project(":core") {
...@@ -77,5 +101,16 @@ project(":core") { ...@@ -77,5 +101,16 @@ project(":core") {
api "com.badlogicgames.gdx:gdx:$gdxVersion" api "com.badlogicgames.gdx:gdx:$gdxVersion"
api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion" api "com.badlogicgames.gdx:gdx-box2d:$gdxVersion"
api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion" api "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$libGDXVersion"
implementation "com.badlogicgames.gdx:gdx-freetype:$gdxVersion"
implementation 'com.google.firebase:firebase-database:20.3.1' // Use the latest version
} }
} }
...@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.GL20; ...@@ -6,6 +6,7 @@ import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.utils.ScreenUtils; import com.badlogic.gdx.utils.ScreenUtils;
import com.wordbattle.game.network.FirebaseInterface;
import com.wordbattle.game.states.MainMenuState; import com.wordbattle.game.states.MainMenuState;
import com.wordbattle.game.states.StateManager; import com.wordbattle.game.states.StateManager;
...@@ -15,10 +16,14 @@ public class WordBattle extends ApplicationAdapter { ...@@ -15,10 +16,14 @@ public class WordBattle extends ApplicationAdapter {
public static final String TITLE = "WordBattle"; public static final String TITLE = "WordBattle";
private StateManager stateManager; private StateManager stateManager;
public SpriteBatch batch; public SpriteBatch batch;
FirebaseInterface _FBIC;
public WordBattle(FirebaseInterface FBIC) {_FBIC = FBIC;}
@Override @Override
public void create() { public void create() {
_FBIC.SomeFunction();
batch = new SpriteBatch(); batch = new SpriteBatch();
stateManager = new StateManager(); stateManager = new StateManager();
ScreenUtils.clear(1, 0, 0, 1); ScreenUtils.clear(1, 0, 0, 1);
......
package com.wordbattle.game.network;
public interface FirebaseInterface {
public void SomeFunction();
}
package com.wordbattle.game.network; package com.wordbattle.game.network;
public class FirebaseManager { public class FirebaseManager implements FirebaseInterface {
private static FirebaseManager instance;
// Private constructor prevents instantiation from other classes
private FirebaseManager() {
// Initialize your FirebaseManager here
}
// Lazy initialization of the instance
public static synchronized FirebaseManager getInstance() {
if (instance == null) {
instance = new FirebaseManager();
}
return instance;
}
@Override
public void SomeFunction() {
System.out.println("Wubbadubdub");
} }
}
package com.wordbattle.game;
import com.wordbattle.game.network.FirebaseInterface;
...@@ -14,6 +14,6 @@ public class DesktopLauncher { ...@@ -14,6 +14,6 @@ public class DesktopLauncher {
String title = WordBattle.TITLE; String title = WordBattle.TITLE;
config.setWindowedMode(width, height); config.setWindowedMode(width, height);
config.setTitle(title); config.setTitle(title);
new Lwjgl3Application(new WordBattle(), config); new Lwjgl3Application(new WordBattle(new DesktopInterfaceClass()), config);
} }
} }
...@@ -2,3 +2,5 @@ org.gradle.daemon=true ...@@ -2,3 +2,5 @@ org.gradle.daemon=true
org.gradle.jvmargs=-Xms128m -Xmx1500m org.gradle.jvmargs=-Xms128m -Xmx1500m
org.gradle.configureondemand=false org.gradle.configureondemand=false
android.enableR8.fullMode=false android.enableR8.fullMode=false
android.useAndroidX=true
android.enableJetifier=true
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment