Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
El Legado De Pintia
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
diegval
El Legado De Pintia
Commits
6f88a95b
Commit
6f88a95b
authored
8 months ago
by
viccall
Browse files
Options
Downloads
Plain Diff
Merge branch 'reparar' into 'develop'
Feature: See merge request
!53
parents
9a355a91
57226667
Branches
Branches containing commit
No related tags found
2 merge requests
!65
Feature:
,
!53
Feature:
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
app/src/main/java/com/example/ellegadodepintia/minijuegoReparacion/MinijuegoReparacion.kt
+25
-14
25 additions, 14 deletions
...legadodepintia/minijuegoReparacion/MinijuegoReparacion.kt
with
25 additions
and
14 deletions
app/src/main/java/com/example/ellegadodepintia/minijuegoReparacion/MinijuegoReparacion.kt
+
25
−
14
View file @
6f88a95b
...
...
@@ -29,6 +29,7 @@ class MinijuegoReparacion : AppCompatActivity() {
var
stop
=
false
val
handler
=
Handler
()
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
soundManager
=
SoundManager
(
this
)
...
...
@@ -77,15 +78,15 @@ class MinijuegoReparacion : AppCompatActivity() {
}
private
fun
agregarFragmentosAlRelativeLayout
(
relativeLayout
:
RelativeLayout
)
{
val
mesaHeightMin
=
1700
val
mesaHeightMax
=
1900
val
mesaHeightMin
=
relativeToHeight
(
1700
)
val
mesaHeightMax
=
relativeToHeight
(
1900
)
for
(
fragmento
in
fragmentos
)
{
val
imageView
=
ImageView
(
this
)
imageView
.
setImageBitmap
(
fragmento
.
bitmap
)
val
params
=
RelativeLayout
.
LayoutParams
(
120
,
120
)
val
params
=
RelativeLayout
.
LayoutParams
(
relativeToWidth
(
120
)
,
relativeToHeight
(
120
)
)
params
.
leftMargin
=
Random
.
nextInt
(
250
,
750
)
params
.
leftMargin
=
Random
.
nextInt
(
relativeToWidth
(
250
)
,
relativeToWidth
(
750
)
)
params
.
topMargin
=
Random
.
nextInt
(
mesaHeightMin
,
mesaHeightMax
)
imageView
.
layoutParams
=
params
...
...
@@ -104,8 +105,8 @@ class MinijuegoReparacion : AppCompatActivity() {
mostrarMartilloGolpe
(
relativeLayout
)
for
((
index
,
fragmento
)
in
fragmentos
.
withIndex
())
{
val
imageView
=
relativeLayout
.
getChildAt
(
index
)
as
?
ImageView
?:
continue
val
margenIzquierdaFinal
=
fragmento
.
columna
*
120
+
250
val
margenArribaFinal
=
fragmento
.
fila
*
120
+
1300
val
margenIzquierdaFinal
=
fragmento
.
columna
*
relativeToWidth
(
120
)
+
relativeToWidth
(
250
)
val
margenArribaFinal
=
fragmento
.
fila
*
relativeToHeight
(
120
)
+
relativeToHeight
(
1300
)
val
precisionRandom
=
Random
.
nextFloat
()
*
0.4f
+
0.6f
val
precision
=
1f
-
(
clics
*
0.20f
)
*
precisionRandom
...
...
@@ -113,7 +114,7 @@ class MinijuegoReparacion : AppCompatActivity() {
val
margenArriba
=
fragmento
.
yPos
+
(
margenArribaFinal
-
fragmento
.
yPos
)
*
precision
val
rotacion
=
fragmento
.
rotation
*
(
1
-
precision
)
val
params
=
RelativeLayout
.
LayoutParams
(
120
,
120
)
val
params
=
RelativeLayout
.
LayoutParams
(
relativeToWidth
(
120
)
,
relativeToHeight
(
120
)
)
params
.
leftMargin
=
margenIzquierda
.
toInt
()
params
.
topMargin
=
margenArriba
.
toInt
()
imageView
.
layoutParams
=
params
...
...
@@ -135,8 +136,8 @@ class MinijuegoReparacion : AppCompatActivity() {
var
para
=
false
val
initialX
=
ruleImageView
.
x
val
initialY
=
ruleImageView
.
y
val
randomX
=
Random
.
nextFloat
()
*
(
1050
-
350
)
val
randomY
=
Random
.
nextFloat
()
*
(
1400
-
250
)
val
randomX
=
Random
.
nextFloat
()
*
(
relativeToWidth
(
1050
)
-
relativeToWidth
(
350
)
)
val
randomY
=
Random
.
nextFloat
()
*
(
relativeToHeight
(
1400
)
-
relativeToHeight
(
250
)
)
ruleImageView
.
x
=
randomX
ruleImageView
.
y
=
randomY
val
deltaX
=
ruleImageView
.
x
-
initialX
...
...
@@ -237,8 +238,8 @@ class MinijuegoReparacion : AppCompatActivity() {
nubeView
.
setBackgroundResource
(
R
.
drawable
.
effect_reparar_animation
)
val
tam
=
Random
.
nextInt
(
150
,
250
)
val
params
=
RelativeLayout
.
LayoutParams
(
tam
,
tam
)
params
.
leftMargin
=
Random
.
nextInt
(
100
,
8
00
)
params
.
topMargin
=
Random
.
nextInt
(
1300
,
1900
)
params
.
leftMargin
=
Random
.
nextInt
(
relativeToWidth
(
100
)
,
relativeToWidth
(
7
00
)
)
params
.
topMargin
=
Random
.
nextInt
(
relativeToHeight
(
1300
)
,
relativeToHeight
(
1900
)
)
nubeView
.
layoutParams
=
params
nubeView
.
rotation
=
Random
.
nextFloat
()*
360
relativeLayout
.
addView
(
nubeView
)
...
...
@@ -261,8 +262,8 @@ class MinijuegoReparacion : AppCompatActivity() {
martilloView
.
setImageResource
(
R
.
drawable
.
asi_reparar_martillo
)
val
tamMartillo
=
Random
.
nextInt
(
300
,
500
)
val
params
=
RelativeLayout
.
LayoutParams
(
tamMartillo
,
tamMartillo
)
params
.
leftMargin
=
Random
.
nextInt
(
100
,
700
)
params
.
topMargin
=
Random
.
nextInt
(
1300
,
1900
)
params
.
leftMargin
=
Random
.
nextInt
(
relativeToWidth
(
100
)
,
relativeToWidth
(
700
)
)
params
.
topMargin
=
Random
.
nextInt
(
relativeToHeight
(
1300
)
,
relativeToHeight
(
1900
)
)
martilloView
.
rotation
=
50f
martilloView
.
layoutParams
=
params
relativeLayout
.
addView
(
martilloView
)
...
...
@@ -283,6 +284,16 @@ class MinijuegoReparacion : AppCompatActivity() {
soundManager
.
stopSound
()
stop
=
true
}
// Funciones auxiliares para convertir a proporciones relativas
private
fun
relativeToWidth
(
value
:
Int
):
Int
{
val
metrics
=
resources
.
displayMetrics
var
screenWidth
=
metrics
.
widthPixels
return
(
value
*
screenWidth
)
/
1080
}
private
fun
relativeToHeight
(
value
:
Int
):
Int
{
val
metrics
=
resources
.
displayMetrics
var
screenHeight
=
metrics
.
heightPixels
return
(
value
*
screenHeight
)
/
2285
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment