Commit 3381aaeb authored by kutyndo3's avatar kutyndo3
Browse files

bla

parents
No related merge requests found
Pipeline #3236 failed with stages
Showing with 377 additions and 0 deletions
+377 -0
.gitignore 0 → 100644
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
.cxx
local.properties
# Default ignored files
/shelf/
/workspace.xml
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<bytecodeTargetLevel target="11" />
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleMigrationSettings" migrationVersion="1" />
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/app" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />
</GradleProjectSettings>
</option>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="DesignSurface">
<option name="filePathToZoomLevelMap">
<map>
<entry key="..\:/Users/kutyndo3/Desktop/nya01/app/src/main/res/drawable/ic_baseline_games_24.xml" value="0.22135416666666666" />
<entry key="..\:/Users/kutyndo3/Desktop/nya01/app/src/main/res/drawable/ic_baseline_image_for_pexeso.xml" value="0.3828125" />
<entry key="..\:/Users/kutyndo3/Desktop/nya01/app/src/main/res/layout/activity_main.xml" value="0.42446709916589437" />
<entry key="..\:/Users/kutyndo3/Desktop/nya01/app/src/main/res/layout/content_main.xml" value="0.25" />
<entry key="..\:/Users/kutyndo3/Desktop/nya01/app/src/main/res/mipmap-anydpi-v26/ic_komi.xml" value="0.3265625" />
</map>
</option>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">
<option name="id" value="Android" />
</component>
</project>
\ No newline at end of file
/build
\ No newline at end of file
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.moxidus.nya01"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.1'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
\ No newline at end of file
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
\ No newline at end of file
package com.moxidus.nya01
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.junit.Test
import org.junit.runner.RunWith
import org.junit.Assert.*
/**
* Instrumented test, which will execute on an Android device.
*
* See [testing documentation](http://d.android.com/tools/testing).
*/
@RunWith(AndroidJUnit4::class)
class ExampleInstrumentedTest {
@Test
fun useAppContext() {
// Context of the app under test.
val appContext = InstrumentationRegistry.getInstrumentation().targetContext
assertEquals("com.moxidus.nya01", appContext.packageName)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.moxidus.nya01">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.Nya01">
<activity
android:name=".MainActivity"
android:exported="true"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/Theme.Nya01.NoActionBar">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
app/src/main/ic_csharp-playstore.png

46.7 KB

app/src/main/ic_gnar-playstore.png

603 KB

app/src/main/ic_java-playstore.png

95 KB

app/src/main/ic_komi-playstore.png

237 KB

app/src/main/ic_miku-playstore.png

352 KB

app/src/main/ic_nagatoro-playstore.png

489 KB

app/src/main/ic_star-playstore.png

28 KB

app/src/main/ic_yuumi-playstore.png

352 KB

package com.moxidus.nya01
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.ui.AppBarConfiguration
import android.widget.GridLayout
import android.widget.ImageView
import androidx.core.view.children
import com.moxidus.nya01.databinding.ActivityMainBinding
import kotlinx.android.synthetic.main.content_main.*
class MainActivity : AppCompatActivity() {
private lateinit var appBarConfiguration: AppBarConfiguration
private lateinit var binding: ActivityMainBinding
var isAnimating = false
var turned: Int = -1 // saves index of turned cards
var score: Int = 0 // saves index of turned cards
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
//setSupportActionBar(binding.toolbar)
//####################################
val LIGHTBLUE = Color.parseColor("#ff8f3a")
val DARKBLUE = Color.parseColor("#ff3a47")
var pexList = (0..7)+(0..7)
pexList = pexList.shuffled()
createAll(LIGHTBLUE, DARKBLUE, pexList)
resetButton.setOnClickListener {
pexList = pexList.shuffled()
turned = -1
score = 0
scoreView.text = score.toString() + "/8"
createAll(LIGHTBLUE, DARKBLUE, pexList)
}
}
private fun createAll(LIGHTBLUE:Int, DARKBLUE:Int , pexList:List<Int>){
board.removeAllViews()
// Dynamically Creates all cards
for (i in 0..15){
val item = ImageView(this, null, R.style.Pexes);
val params = GridLayout.LayoutParams();
params.width = GridLayout.LayoutParams.WRAP_CONTENT
params.height = GridLayout.LayoutParams.WRAP_CONTENT
params.columnSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f)
params.rowSpec = GridLayout.spec(GridLayout.UNDEFINED, 1f)
params.setMargins(5,5,5,5)
item.setBackgroundColor(LIGHTBLUE)
item.layoutParams = params
item.setImageResource(R.drawable.ic_baseline_image_for_pexeso)
board.addView(item)
}
board.children.forEachIndexed { index, view ->
view as ImageView
view.setOnClickListener{
if(!isAnimating){
if (turned == -1){// checks if its the first turned card
turn(index, it as ImageView, pexList)
turned = index;
} else if (index != turned){//makes sure the turned card is not the same as the next one
turn(index, it as ImageView, pexList)
turned = if (pexList[index] == pexList[turned]){
board.getChildAt(index) as ImageView
board.getChildAt(index).setBackgroundColor(DARKBLUE)
board.getChildAt(turned) as ImageView
board.getChildAt(turned).setBackgroundColor(DARKBLUE)
score++;
scoreView.text = score.toString() + "/8"
-1
}else{
turnBack(DARKBLUE)
-1
}
}
}
}
}
}
private fun turnBack(DARKBLUE: Int){
isAnimating = true
Handler(Looper.getMainLooper()).postDelayed({
board.children.forEachIndexed { index, view ->
view as ImageView
val buttonColor = view.background as ColorDrawable
if(buttonColor.color != DARKBLUE)
view.setImageResource(R.drawable.ic_baseline_image_for_pexeso)
}
isAnimating = false
}, 1000)
}
private fun turn(index: Int, view: ImageView, pexesList: List<Int>){
//println("$index is ${pexesList[index]}")
when (pexesList[index]) {
0 -> view.setImageResource(R.mipmap.ic_komi)
1 -> view.setImageResource(R.mipmap.ic_gnar)
2 -> view.setImageResource(R.mipmap.ic_nagatoro)
3 -> view.setImageResource(R.mipmap.ic_miku)
4 -> view.setImageResource(R.mipmap.ic_star)
5 -> view.setImageResource(R.mipmap.ic_csharp)
6 -> view.setImageResource(R.mipmap.ic_java)
7 -> view.setImageResource(R.mipmap.ic_yuumi)
else -> { // Note the block
print("---error")
}
}
}
}
\ No newline at end of file
<vector xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:aapt="http://schemas.android.com/aapt"
android:width="108dp"
android:height="108dp"
android:viewportWidth="108"
android:viewportHeight="108">
<path android:pathData="M31,63.928c0,0 6.4,-11 12.1,-13.1c7.2,-2.6 26,-1.4 26,-1.4l38.1,38.1L107,108.928l-32,-1L31,63.928z">
<aapt:attr name="android:fillColor">
<gradient
android:endX="85.84757"
android:endY="92.4963"
android:startX="42.9492"
android:startY="49.59793"
android:type="linear">
<item
android:color="#44000000"
android:offset="0.0" />
<item
android:color="#00000000"
android:offset="1.0" />
</gradient>
</aapt:attr>
</path>
<path
android:fillColor="#FFFFFF"
android:fillType="nonZero"
android:pathData="M65.3,45.828l3.8,-6.6c0.2,-0.4 0.1,-0.9 -0.3,-1.1c-0.4,-0.2 -0.9,-0.1 -1.1,0.3l-3.9,6.7c-6.3,-2.8 -13.4,-2.8 -19.7,0l-3.9,-6.7c-0.2,-0.4 -0.7,-0.5 -1.1,-0.3C38.8,38.328 38.7,38.828 38.9,39.228l3.8,6.6C36.2,49.428 31.7,56.028 31,63.928h46C76.3,56.028 71.8,49.428 65.3,45.828zM43.4,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2c-0.3,-0.7 -0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C45.3,56.528 44.5,57.328 43.4,57.328L43.4,57.328zM64.6,57.328c-0.8,0 -1.5,-0.5 -1.8,-1.2s-0.1,-1.5 0.4,-2.1c0.5,-0.5 1.4,-0.7 2.1,-0.4c0.7,0.3 1.2,1 1.2,1.8C66.5,56.528 65.6,57.328 64.6,57.328L64.6,57.328z"
android:strokeWidth="1"
android:strokeColor="#00000000" />
</vector>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment