Simple implementation of very popular game Arcanoid. Two game modes multiplayer
and singleplayer
allow to play with friends and break your records. Video of both modes are avaible in multiplayer singleplayer
Each user register his nickname in database. Registration is automatical, it does mean that first login stores nickname in database ( if nickname is available).
When user want to play with friends he need to join or create a room. Each room contains Game configuration (rows, columns, mode(EASY,HARD,MEDIUM)). Room may be created by every user and configured as only he wish.
Lobby is a list of rooms that are open
at the moment. By clicking list item player joins as a guest and contest begin. The one who first destroys all the bricks wins.
multiplayer.mp4
Communication is owed to the firebase. Players listening opponents score and communicating in real time in such way.
When user playing singleplayer mode he just beat next stages and local room
database stores his achievements ( records ).
singleplayer.mp4
private fun addScoreListener() {
messageReference.addValueEventListener(object : ValueEventListener {
override fun onDataChange(snapshot: DataSnapshot) {
if (snapshot.getValue(String::class.java) != null) {
game_view.pauseThread()
basicAlert(snapshot.getValue(String::class.java))
closeRoom()
}
}
override fun onCancelled(error: DatabaseError) {
messageReference.setValue(message)
}
})
}
- firebase
- kotlin
- room
ToDo application in kotlin. This app may be usefull for android users who sometimes forgot about their schedule.
Application allow to add tasks to table in Room
abstract database (database is instantinated using singleton pattern
) which is displayed on main fragment of program. During task inserting procedure program adds alarm
by alarm manager to our phone, so when task is close to expiration date phone vibrates, ringing and user face clickable popup that leads to ToDo
app activity or creates new one.
User can perform operations as read
,add
,delete
,update
, delete-all
, filter
and sort
by every field in task table so we can say that app handles CRUD requests.
Few of them can be found inside menu bar.
Application save instances values in outState and remembers thats how configuration of state after rotation.
User can set priority and type of the task.
Priority is an Enum(HIGH,MEDIUM,LOW)
each value correspond to the appropriate color of task.
Task structure:
data class Task(
@PrimaryKey(autoGenerate = true)
val id: Int,
val name: String,
val date: Date,
val description: String,
val type: String,
val priority: String,
) : Parcelable
Type is responsible for an icon app allows for types as on the screen below:
All tasks can also be viewed via Calendar. Date click lists all tasks assigned to this day as LiveData.
Application handles both landscape and portrait layouts.
private fun setUpNotification(hour: Int, minute: Int, day: Int, month: Int, year: Int) {
val calendar: Calendar = Calendar.getInstance()
calendar.set(Calendar.HOUR_OF_DAY, hour)
calendar.set(Calendar.MINUTE, minute)
calendar.set(Calendar.SECOND, 0)
calendar.set(Calendar.YEAR, year)
calendar.set(Calendar.MONTH, month)
calendar.set(Calendar.DAY_OF_MONTH, day)
if (calendar.time < Date()) calendar.add(Calendar.DAY_OF_MONTH, 1)
val intent = Intent(activity?.applicationContext, NotificationReceiver::class.java)
val pendingIntent = PendingIntent.getBroadcast(
activity?.applicationContext,
(0..2147483647).random(),
intent,
PendingIntent.FLAG_UPDATE_CURRENT
)
val alarmManager =
activity?.getSystemService(AppCompatActivity.ALARM_SERVICE) as AlarmManager
alarmManager.setRepeating(
AlarmManager.RTC_WAKEUP,
calendar.timeInMillis,
AlarmManager.INTERVAL_DAY,
pendingIntent
)
}
- kotlin
- room
Application is some way similar to instagram
. Users of application can take images, rate them and comment.
Main activity handles viewpager2 that switches between gallery and camera page.
Clicking any image object in gallery, which is compressed to achieve better average performance, carries us out with a new intent to a new activity. New activity handles next viewpager2, that represents detailed objects from gallery.
Images are stored in a special directory under media/thisApp path, when details are stored in room database.
Screenshots are available in Layout section.
[CAUTION] Layout requires a little more work
Gallery contains all objects stored in special directory.
Camera is viewpager2's page that allow user to make images and store them in special path + details in room.
Section represent single image stored in application, user has possibility to rate photos and comment them.
private fun takePhoto() {
val imageCapture = imageCapture ?: return
Log.d(Constants.TAG, outputDirectory.toString())
val photoFile = File(
outputDirectory,
SimpleDateFormat(
Constants.FILE_NAME_FORMAT,
Locale.getDefault()
).format(System.currentTimeMillis()) + ".jpg"
)
val savedUri = Uri.fromFile(photoFile)
val outputOption = ImageCapture.OutputFileOptions.Builder(photoFile).build()
imageCapture.takePicture(
outputOption, ContextCompat.getMainExecutor(requireContext()),
object : ImageCapture.OnImageSavedCallback {
override fun onImageSaved(outputFileResults: ImageCapture.OutputFileResults) {
val msg = "Photo saved"
Toast.makeText(
requireActivity(),
"$msg ", Toast.LENGTH_SHORT
).show()
// insert image to database
val img = Image(
0,
path = savedUri.path!!,
description = null,
rating = null
)
mImageViewModel.addImage(img)
}
override fun onError(exception: ImageCaptureException) {
Log.d(Constants.TAG, "onError: ${exception.message}", exception)
}
}
)
}
- xcamera
- kotlin
- room
Hangman game implementation in Kotlin.
private fun onOrientationChange(savedInstanceState: Bundle) {
imageIndex = savedInstanceState.getInt("imageIndex")
displayNextHangmanImage(imageIndex)
currentWord = savedInstanceState.getString("currentWord").toString()
val alreadyDiscoveredLettersAsStr = savedInstanceState.getString("alreadyDiscoveredLetters")
if (alreadyDiscoveredLettersAsStr != null) {
alreadyDiscoveredLetters = alreadyDiscoveredLettersAsStr.split(" ").toHashSet()
}
showBlurredWord(currentWord)
for (x in alreadyDiscoveredLetters) {
showLetter(x)
}
}
- kotlin
TicTacToe game implementation in Kotlin.
Games offers 2 boards in size 3x3 and 5x5.
Players can play kotlin.maxint rounds and still recognize who is winning.
Example win in 5x5 board mode.
private fun onButtonClick(button: Button, r: Int, c: Int) {
if (!isFieldBusy(button)) {
if (player1Turn) {
button.text = player1Symbol
button.setBackgroundColor(Color.parseColor("#5e60ce"))
player1Turn = false
player1Fields.add(intArrayOf(r, c))
if (hasWin(player1Fields)) {
basicAlert(findViewById(R.id.resetButton), "Player1 has won")
player1Score += 1
updateScore(player1ScoreTextView, player1Score)
}
} else {
button.text = player2Symbol
button.setBackgroundColor(Color.parseColor("#64dfdf"))
player1Turn = true
player2Fields.add(intArrayOf(r, c))
if (hasWin(player2Fields)) {
basicAlert(findViewById(R.id.resetButton), "Player2 has won")
player2Score += 1
updateScore(player2ScoreTextView, player2Score)
}
}
if ((player1Fields.size + player2Fields.size).toDouble() == size.toDouble().pow(2.0)) {
basicAlert(findViewById(R.id.resetButton), "Draw")
roundCounter++
}
} else {
Toast.makeText(applicationContext, "Field is busy.", Toast.LENGTH_SHORT).show()
}
}
- kotlin
Rock paper scissors. Simple game implementation in Kotlin.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
val view = binding.root
setContentView(view)
if (savedInstanceState != null) {
val value = savedInstanceState.getInt("counter")
binding.counter.text = value.toString()
counter = value
}
}
- kotlin
- REACTJS
- RUN REACT-NATIVE CLONED PROJECT
OPTIONAL
EXPOnpm install -g expo-cli
- Run android emulator
- Run npm server
npm start
- Deploy game on emulator
Simple color focus
written in react-native
. There are three buttons with correct labels
but wrong colors. User need to click button in background color as fast as only he can.
Game improves focus ability.
export default class App extends React.Component {
state = {
bcg: 'blue',
points: 0
}
handleUpdate(value, bcg) {
if (value.toLowerCase() == bcg) {
this.setState({
bcg: randomColor(),
points: this.state.points + 1
})
} else {
this.setState({bcg: randomColor(), points: this.state.points-1})
}
}
render() {
return (
<View
style={{
flex: 1,
backgroundColor: this.state.bcg,
alignItems: 'center',
justifyContent: 'center'
}}>
<Text style={{
flex: 1,
fontSize: 24,
color: 'white'
}}>Points: {this.state.points}</Text>
<StatusBar style="auto"/>
<View style={styles.btnBox}>
<View style={styles.btn}>
<Button
title="RED"
color="blue"
onPress={() => this.handleUpdate("red", this.state.bcg)}></Button>
</View>
<View style={styles.btn}>
<Button title="BLUE" color="green" onPress={() => this.handleUpdate("blue", this.state.bcg)}></Button>
</View>
<View style={styles.btn}>
<Button title="GREEN" color="red" onPress={() => this.handleUpdate("green", this.state.bcg)}></Button>
</View>
</View>
</View>
);
}
}
- react-native
- expo
- nodejs