Skip to content

Some implementations of games like `Instagram`, Roshambo, Hangman and more useful things as ToDo, Arcanoid app. Programs are solutions for university course.

Notifications You must be signed in to change notification settings

sqoshi/mobile-applications

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table Of Contents


Arcanoid

Introduction

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

General Info

Each user register his nickname in database. Registration is automatical, it does mean that first login stores nickname in database ( if nickname is available).

Multiplayer

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.

Video

multiplayer.mp4

Database

Communication is owed to the firebase. Players listening opponents score and communicating in real time in such way.

Singleplayer

When user playing singleplayer mode he just beat next stages and local room database stores his achievements ( records ).

Video

singleplayer.mp4

Code Example

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)
        }

    })
}

Technologies

  • firebase
  • kotlin
  • room

Introduction

ToDo application in kotlin. This app may be usefull for android users who sometimes forgot about their schedule.

General Info

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.

Sorts

Filter by priority

Priority is an Enum(HIGH,MEDIUM,LOW) each value correspond to the appropriate color of task.

Task structure

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

Icon chooser

Type is responsible for an icon app allows for types as on the screen below:

Calendar

All tasks can also be viewed via Calendar. Date click lists all tasks assigned to this day as LiveData.

Layout

Application handles both landscape and portrait layouts.

Portrait

Tasks list

Task update

Task deletion

All tasks deletion

Landscape

Tasks list

Task addition

Code Example

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
        )
    }

Technologies

  • kotlin
  • room

Snapgram

Introduction

Application is some way similar to instagram. Users of application can take images, rate them and comment.

General Info

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.

Layout

[CAUTION] Layout requires a little more work

Gallery

Gallery contains all objects stored in special directory.

Camera

Camera is viewpager2's page that allow user to make images and store them in special path + details in room.

Image

Section represent single image stored in application, user has possibility to rate photos and comment them.

Code Example

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)
                }

            }
        )

    }

Technologies

  • xcamera
  • kotlin
  • room

Hangman game implementation in Kotlin.

Layout

Portrait

Landscape

Lost Popup

Code Example

    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)
        }

    }

Technologies

  • 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.

Layout

Main

Board3x3

Round Win

Example win in 5x5 board mode.

Code Example

    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()

        }
    }

Technologies

  • kotlin

Rock paper scissors. Simple game implementation in Kotlin.

Layout

Portrait

Landscape

Code Example

    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
        }
    }

Technologies

  • kotlin

Color Focus

Installation

  1. REACTJS
  2. RUN REACT-NATIVE CLONED PROJECT
  3. OPTIONAL EXPO npm install -g expo-cli

Launch

  1. Run android emulator
  2. Run npm server npm start
  3. Deploy game on emulator

Introduction

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.

General Info

Game improves focus ability.

Code Example

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>

        );
    }
}

Technologies

  • react-native
  • expo
  • nodejs

About

Some implementations of games like `Instagram`, Roshambo, Hangman and more useful things as ToDo, Arcanoid app. Programs are solutions for university course.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published