Display activity on 2 android devices simultaneously over a network - java

I have to create a simple single and multiplayer game in android about tilting the phone and recording the quickest time in a certain direction. I have successfully managed to create the single player version in Java. However I have no clue where to start with the multiplayer option where the game starts simultaneously on both devices where one is a server and the other the client (decided beforehand by the 2 people). I did take a look at the Android p2p website, but it wasn't much help. I have used Android Studio for the project.
I have all the math and logic ready from the single player, I am only struggling to how I can start the multiplayer by displaying an activity on 2 separate devices simultaneously. Unfortunately I don't have code to show for multiplayer as I have no idea where to begin.
Any help or advice will be highly appreciated.

Related

Uninterrupted background music across all activities in Android Studio game

I am currently working on a game in Android Studio and am having issues with implementing a constant soundtrack across all activities. The way I want it to work is that when the app is started up, an audio file will begin playing and looping and will continue looping throughout all activities, and essentially never end (or restarted when changing activities). At some point I would also add a mute/silent button as well. My question really is, how can I create a class for this sound file to play on repeat upon booting the app and also continue without interruption when changing activities. As it currently stands I have a few lines declaring a Mediaplayer object and setting it to loop and playing it, within each activity.. I realize this is not an efficient implementation but I am brand new to Android Studio and still figuring this out.
Follow this tutorial:
https://www.codeproject.com/Articles/258176/Adding-Background-Music-to-Android-App
And start the Music Service in your MainActivity, if there are still any issues, then let me know.

How to add multiplayer in Android?

I'm making a Tic Tac Toe game in Android with three options:One player, two players and multiplayer.
The first two options were easy to make but I'm having A LOT of troubles with the last one, I have no idea what to do.
I am a beginner java programmer and I've never worked on networking with java, I know some basic things like MySQL and web stuff but I dont think it has anything to do with android.
So my questions are:
Do I have to use a server for this type of game? how and where do I find servers for this?
What do I need to learn in order to have the knowledge for developing multiplayer games?
Is it possible to make players play with other random available players? just hit play and be ready to go.
Can you recommend me some good guides that could help me?
Thank you very much !
Try Firebase
Firebase can act as a server where the users are connected
Firebase provides Realtime Database which would help your app. for eg
when a player makes a move, the changes would be effected to all the other player devices in Realtime by Firebase itself, you won't have to write the code to keep them in Sync
I recommend you take a look at Google Play Games Services.
It comes with a tone of features, and, most important for you, it has a Turn Based Multiplayer option that you could maybe use in your Tic Tac Toe.

Integrating multimedia with LibGDX

According to the LibGDX web page:
Android applications can have multiple activities. Libgdx games should usually only consist of a single activity. Different screens of the game are implemented within libgdx, not as separate activities. The reason for this is that creating a new Activity also implies creating a new OpenGL context, which is time consuming and also means that all graphical resources have to be reloaded.
However, this isn't impossible to do - just undesirable.
I'm building an app that is designed to hold a few games built in LibGDX, as well as some information alongside it - video/audio, text with illustrations, and so on, describing the development of the games.
Is it a better idea to build this as a native android application that launches and tears down LibGDX whenever the user wants to play a game? Or should I write the entire app through LibGDX and do try and do the non-game stuff using UI libraries and so on?
I'm sorry I can't nail this down to a more specific question. I'm really interested to know before I embark down the wrong road.
The consensus in a linked Reddit thread here is that setting up and tearing down a LibGDX activity isn't such a huge overhead, particularly if the games are small (which they are in my case).
I'm going to opt for this solution, and simply shut down the activity whenever the user stops playing a game.

Multi-Connection bluetooth application

I am developing a J2ME MIDP 2.0 game that can can be played over bluetooth,
it is similar to tic tac toe where players exchange turns until the game is over,
the problem is that i want to give the both players the ability to restart the game or quit
at any time but i only have one connection for transferring game related data, and i wonder if i could have two separate connections between the two devices at the same time, one for eg. game management (restart, quit, etc ..) and the other for game data to separate the logic.
or you could put it this way : is it possible to have multiple bluetooth connections between two MIDP devices at the same time ?
Thanks in advance
I think for bluetooth.Via j2me mobile application the Midp device is connected at most only one device and at most at a time only one connection is enabled.So there is no chance of going to multiple connections.

java : voice chat and text chat

I want to make a card game made in Java. People can run it on their pc. They can add their friends to their contacts list and when there are 4 players online they can begin a game by one of the players hosting the game. The players can communicate by text or by voice chat Think of it like a chat client that allows users to play a card game and allows voice chat between the 4 players at the same time.
i dont know how do go abt the above project.Can anyone suggest me
some framework or other things that i can use to devlop the above app?
Will it be like a p2p application?
Start with chat using this tutorial. Run your own jabber client or use gTalk and write some code for the client side.
As I understand you are going to make some kind of browser or desktop game app with both text and audio chat options.
For chat app you will need a backend and client-side solutions.
If I understand you right, you have not much experience with chat apps, so preparing everything from scratch might be tricky for you.
Therefore, I'd recommend trying a ready backend and SDK for developing chat and audio chat part of your app. That should spare a lot of effort and work for you and you will be able to concentrate on UI implementation of your chat and audio chat.
Since you need both text chat and audio chat solutions, I can recommend ConnectyCube, since there you can find both at one place.
For browser or desktop apps you can use JS SDK. Here is the documentation how to connect it to your project.

Categories