Compare commits

...

2 Commits

3 changed files with 72 additions and 11 deletions

View File

@@ -2,6 +2,7 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"> xmlns:tools="http://schemas.android.com/tools">
<uses-feature android:glEsVersion="0x00020000" android:required="true"/> <uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<uses-permission android:name="android.permission.INTERNET" />
<application <application
android:allowBackup="true" android:allowBackup="true"
android:fullBackupContent="true" android:fullBackupContent="true"

View File

@@ -0,0 +1,40 @@
package com.iofferyoutea.WitchQueen
import com.badlogic.gdx.Gdx
import com.badlogic.gdx.Net
class Lobby {
//val localServers: MutableSetOf<String> = setOf<String>() <-- HashSet?
//val localPlayer: Player = <-- Should be local player. Has all their items etc.
//val lobby: MutableList<Player> = listOf<Player>(localPlayer) <-- Limit to lobby size (2)?
val serverSocket = Gdx.net.newServerSocket(
Net.Protocol.TCP,
"127.0.0.1",
2864,
null
)
val clientSocket = Gdx.net.newClientSocket(
Net.Protocol.TCP,
"127.0.0.1", // <- This should be other servers address
2864, // <- This should be other servers port
null
)
val inputStream = clientSocket.inputStream
private fun findLocalServer() {
Gdx.app.log("Lobby", "Finding local server...")
}
private fun replayHasLocalServer(remoteAddress: String, remotePort: Int) {
Gdx.app.log("Lobby", "Pinged by another client. Informing that we have an open lobby...")
}
private fun connectToServer(ip: String, port: Int) { // String is the ideal type for ip because v6 uses letters too?
Gdx.app.log("Lobby", "Connecting to $ip on port $port...")
}
}

View File

@@ -2,7 +2,10 @@ package com.iofferyoutea.WitchQueen
import com.badlogic.gdx.Gdx import com.badlogic.gdx.Gdx
import com.badlogic.gdx.graphics.Texture import com.badlogic.gdx.graphics.Texture
import com.badlogic.gdx.graphics.g2d.Batch
import com.badlogic.gdx.graphics.g2d.BitmapFont import com.badlogic.gdx.graphics.g2d.BitmapFont
import com.badlogic.gdx.graphics.g2d.SpriteBatch
import com.badlogic.gdx.graphics.g3d.ModelCache
import com.badlogic.gdx.scenes.scene2d.InputEvent import com.badlogic.gdx.scenes.scene2d.InputEvent
import com.badlogic.gdx.scenes.scene2d.Stage import com.badlogic.gdx.scenes.scene2d.Stage
import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle import com.badlogic.gdx.scenes.scene2d.ui.Button.ButtonStyle
@@ -15,12 +18,16 @@ import com.badlogic.gdx.scenes.scene2d.ui.VerticalGroup
import com.badlogic.gdx.scenes.scene2d.utils.ClickListener import com.badlogic.gdx.scenes.scene2d.utils.ClickListener
import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable import com.badlogic.gdx.scenes.scene2d.utils.TextureRegionDrawable
import com.badlogic.gdx.utils.Logger import com.badlogic.gdx.utils.Logger
import com.badlogic.gdx.utils.Scaling
import com.badlogic.gdx.utils.viewport.ScreenViewport import com.badlogic.gdx.utils.viewport.ScreenViewport
import com.badlogic.gdx.utils.viewport.StretchViewport
import com.badlogic.gdx.utils.viewport.Viewport import com.badlogic.gdx.utils.viewport.Viewport
import ktx.actors.centerPosition import ktx.actors.centerPosition
import ktx.actors.setPosition import ktx.actors.setPosition
import ktx.actors.stage
import ktx.app.KtxScreen import ktx.app.KtxScreen
import ktx.app.clearScreen import ktx.app.clearScreen
import javax.swing.text.View
class MainMenu : KtxScreen { class MainMenu : KtxScreen {
val myTable = Table().apply { val myTable = Table().apply {
@@ -28,7 +35,10 @@ class MainMenu : KtxScreen {
setFillParent(true) setFillParent(true)
} }
val myStage = Stage().apply { val myStage = Stage().apply {
Gdx.input.inputProcessor = this
addActor(myTable) addActor(myTable)
// We need this to get the size of the table later
//myTable.setSize(viewport.screenWidth.toFloat(), viewport.screenHeight.toFloat())
} }
//region Map Button //region Map Button
@@ -42,32 +52,28 @@ class MainMenu : KtxScreen {
) )
val mapButton = ImageButton(mapButtonStyle).apply { val mapButton = ImageButton(mapButtonStyle).apply {
myTable.add(this) myTable.add(this)
myTable.getCell<ImageButton>(this).padBottom(myStage.viewport.screenHeight * 0.05f) // Figure out how to centre myTable.getCell<ImageButton>(this)
} }
//endregion //endregion
//endregion
//region Player Buttons //region Player Buttons
// Local Player // Local Player
// Remote Player // Remote Player
val remotePlayerButton = PlayerButton().apply { val remotePlayerButton = PlayerButton().apply {
myTable.row() myTable.row()
myTable.add(this.playerGroup) myTable.add(this.playerGroup)
myTable.getCell<HorizontalGroup>(this.playerGroup).padBottom(myStage.viewport.screenHeight * 0.05f) // You've got to size the sub actors! myTable.getCell<HorizontalGroup>(this.playerGroup) // You've got to size the sub actors!
} }
//endregion
//region Play Buttons //region Play Buttons
val casualButtonStyle = TextButton.TextButtonStyle( val casualButtonStyle = TextButton.TextButtonStyle(
TextureRegionDrawable(Texture("default.png")), TextureRegionDrawable(Texture("default.png")),
TextureRegionDrawable(Texture("default.png")), TextureRegionDrawable(Texture("default_flipped.png")),
TextureRegionDrawable(Texture("default.png")), TextureRegionDrawable(Texture("default.png")),
BitmapFont() BitmapFont()
) )
val casualButton = TextButton("Casual", casualButtonStyle).apply { val casualButton = TextButton("Casual", casualButtonStyle)
myTable.row() // Start with a new row
myTable.add(this)
myTable.getCell<TextButton>(this)
}
val competitiveButtonStyle = TextButton.TextButtonStyle( val competitiveButtonStyle = TextButton.TextButtonStyle(
TextureRegionDrawable(Texture("default.png")), TextureRegionDrawable(Texture("default.png")),
@@ -75,17 +81,31 @@ class MainMenu : KtxScreen {
TextureRegionDrawable(Texture("default.png")), TextureRegionDrawable(Texture("default.png")),
BitmapFont() BitmapFont()
) )
val competitiveButton = TextButton("Competitive", competitiveButtonStyle).apply { val competitiveButton = TextButton("Competitive", competitiveButtonStyle)
// We need to wrap the play buttons in a group so they only take up 1 column
val playButtonGroup = HorizontalGroup().apply {
addActor(casualButton)
addActor(competitiveButton)
myTable.row()
myTable.add(this) myTable.add(this)
myTable.getCell<TextButton>(this).padLeft(myStage.viewport.screenWidth * 0.1f) myTable.getCell<HorizontalGroup>(this)
} }
//endregion //endregion
private fun update(delta: Float) {
if (casualButton.isPressed) {
Gdx.app.log("MainMenu", "Casual Button Pressed!")
}
}
override fun render(delta: Float) { override fun render(delta: Float) {
clearScreen(0.3f, 0.3f, 0.3f) clearScreen(0.3f, 0.3f, 0.3f)
myStage.act(delta) myStage.act(delta)
myStage.draw() myStage.draw()
update(delta)
} }
override fun dispose() { override fun dispose() {