├── AndroidManifest.xml
├── LICENSE
├── MainActivity.kt
├── activity_main.xml
├── content_main.xml
├── drawable
├── camel.png
├── coala.png
├── code.png
├── fox.png
├── lion.png
├── monkey.png
└── wolf.png
└── fullProgram
├── app-debug.apk
├── memoryGame.zip
└── this
/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | This is free and unencumbered software released into the public domain.
2 |
3 | Anyone is free to copy, modify, publish, use, compile, sell, or
4 | distribute this software, either in source code form or as a compiled
5 | binary, for any purpose, commercial or non-commercial, and by any
6 | means.
7 |
8 | In jurisdictions that recognize copyright laws, the author or authors
9 | of this software dedicate any and all copyright interest in the
10 | software to the public domain. We make this dedication for the benefit
11 | of the public at large and to the detriment of our heirs and
12 | successors. We intend this dedication to be an overt act of
13 | relinquishment in perpetuity of all present and future rights to this
14 | software under copyright law.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 | OTHER DEALINGS IN THE SOFTWARE.
23 |
24 | For more information, please refer to
25 |
--------------------------------------------------------------------------------
/MainActivity.kt:
--------------------------------------------------------------------------------
1 | // Memory Game
2 | // By Kurt Kaiser
3 | // kurtkaiser.us
4 |
5 | package com.example.memorygame
6 | import android.annotation.SuppressLint
7 | import android.os.Bundle
8 | import android.support.v7.app.AppCompatActivity
9 | import com.example.memorygame.R.drawable.*
10 |
11 | import kotlinx.android.synthetic.main.activity_main.*
12 | import kotlinx.android.synthetic.main.content_main.*
13 | class MainActivity : AppCompatActivity() {
14 |
15 | @SuppressLint("SetTextI18n")
16 | override fun onCreate(savedInstanceState: Bundle?) {
17 | super.onCreate(savedInstanceState)
18 | setContentView(R.layout.activity_main)
19 | setSupportActionBar(toolbar)
20 |
21 | val images: MutableList =
22 | mutableListOf(camel, coala, fox, lion, monkey, wolf, camel, coala, fox, lion, monkey, wolf)
23 |
24 | val buttons = arrayOf(button1, button2, button3, button4, button5, button6, button7, button8,
25 | button9, button10, button11, button12)
26 |
27 | val cardBack = code
28 | var clicked = 0
29 | var turnOver = false
30 | var lastClicked = -1
31 |
32 | images.shuffle()
33 | for(i in 0..11){
34 | buttons[i].setBackgroundResource(cardBack)
35 | buttons[i].text = "cardBack"
36 | buttons[i].textSize = 0.0F
37 | buttons[i].setOnClickListener {
38 | if (buttons[i].text == "cardBack" && !turnOver) {
39 | buttons[i].setBackgroundResource(images[i])
40 | buttons[i].setText(images[i])
41 | if (clicked == 0) {
42 | lastClicked = i
43 | }
44 | clicked++
45 | } else if (buttons[i].text !in "cardBack") {
46 | buttons[i].setBackgroundResource(cardBack)
47 | buttons[i].text = "cardBack"
48 | clicked--
49 | }
50 |
51 | if (clicked == 2) {
52 | turnOver = true
53 | if (buttons[i].text == buttons[lastClicked].text) {
54 | buttons[i].isClickable = false
55 | buttons[lastClicked].isClickable = false
56 | turnOver = false
57 | clicked = 0
58 | }
59 | } else if (clicked == 0) {
60 | turnOver = false
61 | }
62 | }
63 | }
64 |
65 | }
66 |
67 | }
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/activity_main.xml:
--------------------------------------------------------------------------------
1 | // Memory Game
2 | // By Kurt Kaiser
3 | // kurtkaiser.us
4 |
5 |
6 |
13 |
14 |
18 |
19 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/content_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
11 |
12 |
20 |
29 |
40 |
49 |
50 |
59 |
70 |
79 |
80 |
89 |
100 |
109 |
118 |
129 |
138 |
139 |
140 |
141 |
142 |
--------------------------------------------------------------------------------
/drawable/camel.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/drawable/camel.png
--------------------------------------------------------------------------------
/drawable/coala.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/drawable/coala.png
--------------------------------------------------------------------------------
/drawable/code.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/drawable/code.png
--------------------------------------------------------------------------------
/drawable/fox.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/drawable/fox.png
--------------------------------------------------------------------------------
/drawable/lion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/drawable/lion.png
--------------------------------------------------------------------------------
/drawable/monkey.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/drawable/monkey.png
--------------------------------------------------------------------------------
/drawable/wolf.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/drawable/wolf.png
--------------------------------------------------------------------------------
/fullProgram/app-debug.apk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/fullProgram/app-debug.apk
--------------------------------------------------------------------------------
/fullProgram/memoryGame.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/kurtkaiser/memoryGameAndroid/d6057268afd9959b83d59af4312069103793d7ce/fullProgram/memoryGame.zip
--------------------------------------------------------------------------------
/fullProgram/this:
--------------------------------------------------------------------------------
1 | This is on the good days
2 |
--------------------------------------------------------------------------------