-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.lua
893 lines (670 loc) · 22.1 KB
/
play.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
local composer = require( "composer" )
local scene = composer.newScene()
-- -----------------------------------------------------------------------------------
-- Code outside of the scene event functions below will only be executed ONCE unless
-- the scene is removed entirely (not recycled) via "composer.removeScene()"
-- ----------------------------------------------------------------------------------
-- -----------------------------------------------------------------------------------
-- Scene event functions
-- -----------------------------------------------------------------------------------
-- create()
function scene:create( event )
local appodeal = require "plugin.appodeal"
local function adListener( event )
if ( event.phase == "init" ) then -- Successful initialization
print( event.isError )
end
end
-- Initialize the Appodeal plugin
appodeal.init( adListener, { appKey="24f5beee36bf72ef15abcbb9ad0ab5ae08421659903ab548" } )
local w = display.contentWidth -- largura da tela
local h = display.contentHeight -- altura da tela
--inicializaçao de atributos
local estadoDaMovimentacao = 1
local posicaoDofundo = -8000
local movimentoDeFundo = 0
local vlsMovimentacaoVertical = 0
local posicaoVerticalVls = display.contentHeight - 30
local altitude = 0
local aceleracao = 0
local estadoDojogo = 0 -- 0 - vls na base 1 - vls fora dela 2 - game over
local quantidadeDeExp = 0
local expMinimo = 0
local aceMinimo = 10
local contador4 = 0
local contador3 = 0
local contador2 = 0
local contador22 = 0
local estadoAlerta = 0
local function posicaoHorizontalIconis()
local x = math.random(1,3)
if x == 1 then
return 160
end
if x == 2 then
return 80
end
if x == 3 then
return 240
end
end
local function posicaoVerticalIconis()
return math.random(-400,-10)
end
local background = display.newImage("background.png",0,0,display.contentWidth , display.contentHeight + 1000000) -- cria uma nova imagem de fundo
background.myName = "fundo"
local sheetData2 = { width = 13 , height = 44 , numFrames=2 }
-- width: largura de cada frame
-- height: altura de cada frame
-- numFrames: número de frames da sprite
local sheet2 = graphics.newImageSheet("fogo.png", sheetData2)
-- cria uma nova imagem usando a sprite "gaara.png" e as propriedades vistas acima
local sequenceData2 =
{
{name ="fogo", start = 1, count = 2, time = 100, loopCount = 0 },
{name ="parado", start = 1, count = 1, time = 100, loopCount = 1 }
-- name: nome desse movimento
-- start: frame da sprite onde a animação começa (nesse caso começa no primeiro frame da sprite)
-- count: número de frames para essa animação (nesse caso essa animação só terá um frame, o primeiro, aquele q o gaara tá parado pra baixo)
-- time: tempo de duração da animação (está zero pq essa animação só tem um quadro
-- loopCount: número de vezes que a animação é executada, nesse caso a animação só é executada uma vez, pois só tem um frame
}
local sheetData = { width = 65.3 , height = 64.3 , numFrames=4 }
-- width: largura de cada frame
-- height: altura de cada frame
-- numFrames: número de frames da sprite
local sheet = graphics.newImageSheet("icone.png", sheetData)
-- cria uma nova imagem usando a sprite "gaara.png" e as propriedades vistas acima
local sequenceData =
{
{name = "experiencia", start = 1, count = 2, time = 150, loopCount = 0 },
-- name: nome desse movimento
-- start: frame da sprite onde a animação começa (nesse caso começa no primeiro frame da sprite)
-- count: número de frames para essa animação (nesse caso essa animação só terá um frame, o primeiro, aquele q o gaara tá parado pra baixo)
-- time: tempo de duração da animação (está zero pq essa animação só tem um quadro
-- loopCount: número de vezes que a animação é executada, nesse caso a animação só é executada uma vez, pois só tem um frame
{name = "dinheiro", start = 3, count = 2 , time = 150 , loopCount = 0}
}
--[[
local sheetData2 = { width = 120 , height = 107.29, numFrames=11 }
-- width: largura de cada frame
-- height: altura de cada frame
-- numFrames: número de frames da sprite
local sheet2 = graphics.newImageSheet("vls.png", sheetData2)
-- cria uma nova imagem usando a sprite "gaara.png" e as propriedades vistas acima
local sequenceData2 =
{
{name = "explossao", start = 2, count = 2, time = 350, loopCount = 1 },
{name = "normal", start = 1, count = 1, time = 500, loopCount = 1 },
{name = "n", start = 9, count = 1, time = 500, loopCount = 1 },
{name = "s", start = 4, count = 6, time = 450, loopCount = 1 },
{name = "explossao2", start = 10, count = 2, time = 350, loopCount = 1 }
-- name: nome desse movimento
-- start: frame da sprite onde a animação começa (nesse caso começa no primeiro frame da sprite)
-- count: número de frames para essa animação (nesse caso essa animação só terá um frame, o primeiro, aquele q o gaara tá parado pra baixo)
-- time: tempo de duração da animação (está zero pq essa animação só tem um quadro
-- loopCount: número de vezes que a animação é executada, nesse caso a animação só é executada uma vez, pois só tem um frame
}
]]
local fogo = display.newSprite(sheet2,sequenceData2)
fogo:setSequence("parado")
local fogo2 = display.newSprite(sheet2,sequenceData2)
fogo2:setSequence("parado")
local function sequence(i)
local x = math.random(0,2)
if x == 1 then
i.myName = "dinheiro"
i:setSequence("dinheiro")
end
if x == 2 then
i.myName = "experiencia"
i:setSequence("experiencia")
end
end
local moviFogo = 0
local iconis = {}
--posicaoHorizontalIconis()
--posicaoVerticalIconis()
iconis[1] = display.newSprite(sheet,sequenceData)
iconis[1].x = posicaoHorizontalIconis()
iconis[1].y = posicaoVerticalIconis()
sequence(iconis[1])
iconis[1].objType = "1"
--posicaoHorizontalIconis()
--posicaoVerticalIconis()
iconis[2] = display.newSprite(sheet,sequenceData)
iconis[2].x = posicaoHorizontalIconis()
iconis[2].y = posicaoVerticalIconis()
sequence(iconis[2])
iconis[2].objType = "2"
iconis[3] = display.newSprite(sheet,sequenceData)
iconis[3].x = posicaoHorizontalIconis()
iconis[3].y = posicaoVerticalIconis()
sequence(iconis[3])
iconis[3].objType = "3"
iconis[4] = display.newSprite(sheet,sequenceData)
iconis[4].x = posicaoHorizontalIconis()
iconis[4].y = posicaoVerticalIconis()
sequence(iconis[4])
iconis[4].objType = "4"
local final = display.newImage("final.png")
final.x = 150
final.width =display.contentWidth + 200
final.height = 250
final.y = -200
local vls = display.newImage("vls.png",0,0)
vls.width = 40
vls.height = 70
--vls:setSequence("normal")
vls.x = display.contentCenterX
vls.y = posicaoVerticalVls
vls.myName = "vls"
--local background = display.newRect(0,0, display.contentWidth ,display.contentHeight)
--background:setFillColor( 255, 255, 255 ) 0
local physics = require("physics")
physics.start()
--physics.setDrawMode( "hybrid" )
physics.setGravity(0, 0) -- Adiciona a variavel gravidade na fisica
physics.addBody(iconis[1], "dynamic", {bounce=0.0, friction=0.3})
physics.addBody(iconis[2], "dynamic", {bounce=0.0, friction=0.3})
physics.addBody(iconis[3], "dynamic", {bounce=0.0, friction=0.3})
physics.addBody(iconis[4], "dynamic", {bounce=0.0, friction=0.3})
physics.addBody( vls, "dynamic", {density=400, radius=10, bounce=0.0 }, { box={ halfWidth=8, halfHeight=50, x=0, y=2}, isSensor=true })
iconis[1].isFixedRotation = true
iconis[2].isFixedRotation = true
iconis[3].isFixedRotation = true
iconis[4].isFixedRotation = true
background.x = display.contentCenterX
background.y = posicaoDofundo
background.height = 30000
background.width = w
local fumacaEsquerda = display.newImageRect("fumacaEsquerda.png",50,25)
fumacaEsquerda.x = 165
fumacaEsquerda.y = 470
fumacaEsquerda.xScale = 0.1
fumacaEsquerda.alpha = 0
local fumacaDireita = display.newImageRect( "fumacaDireita.png",50,25)
fumacaDireita.x = 155
fumacaDireita.y = 470
fumacaDireita.xScale = 0.1
fumacaDireita.alpha = 0
local final2 = display.newImage("final2.png")
final2.x = 150
final2.width =display.contentWidth + 200
final2.height = 1000
final2.y = -300
local gamerover = display.newImage("gamerover.png")
gamerover.width = 290
gamerover.height = 310
gamerover.x = display.contentCenterX - 2
gamerover.y = 270
gamerover.alpha = 0
appodeal.show( "interstitial" )
local textoAltitude2 = display.newText(altitude,160,175,native.systemFont,30)
local textoAceleracao2 = display.newText(aceleracao,225,383,native.systemFont,30)
local textoQuantidadeDeExp2 = display.newText(quantidadeDeExp,225,323,native.systemFont,30)
textoAceleracao2.alpha = 0
textoAltitude2.alpha = 0
textoQuantidadeDeExp2.alpha = 0
local nasai = audio.loadStream( "NASAi.mp3" )
local nasaiChannel
local nasar = audio.loadStream( "NASAr.mp3" )
local nasarChannel
local aux = 0
local touchFunction = function(e)
local eventName = e.phase
local direction = e.target.myName
--if eventName == "began" or eventName == "moved" then
if direction == "acelerar" and estadoDojogo ~= 2 and aceleracao < 150 then
if aceleracao == 0 then
nasaiChannel = audio.play( nasai, { channel=10, loops=0, fadein=50 } )
nasarChannel = audio.play( nasar, { channel=9, loops=-1, fadein=2000 } )
movimentoDeFundo = movimentoDeFundo + 1
vlsMovimentacaoVertical = vlsMovimentacaoVertical - 1
movimentoDeFundo = movimentoDeFundo + 1
estadoDojogo = 1
aceleracao = aceleracao + 10
fumacaEsquerda.alpha = 1
fumacaDireita.alpha = 1
transition.to(fumacaEsquerda,{time = 4500, xScale = 5.0, yScale = 6.5, x = 50 , y = 450 })
transition.to(fumacaDireita,{time = 4500, xScale = 5.0, yScale = 6.5, x = 270 , y = 450 })
fogo:setSequence("fogo")
fogo:play()
fogo2:setSequence("fogo")
fogo2:play()
fumacaDireita.e = 1
else
movimentoDeFundo = movimentoDeFundo + 0.1
vlsMovimentacaoVertical = vlsMovimentacaoVertical - 0.1
movimentoDeFundo = movimentoDeFundo + 0.1
estadoDojogo = 1
aceleracao = aceleracao + 1
end
end
if direction == "frear" and aceleracao > 0 then
posicaoVerticalVls = posicaoVerticalVls + 0.1
movimentoDeFundo = movimentoDeFundo - 0.1
vlsMovimentacaoVertical = vlsMovimentacaoVertical + 0.1
movimentoDeFundo = movimentoDeFundo - 0.1
if aceleracao > 0 then
aceleracao = aceleracao - 1
end
end
if direction == "fundo" and estadoDojogo ~= 0 then
--reiniciando o jogo
if aux >= 2 then
gamerover.alpha = 0
vls.rotation = 0
estadoDaMovimentacao = 1
posicaoDofundo = -8000
movimentoDeFundo = 0
vlsMovimentacaoVertical = 0
posicaoVerticalVls = display.contentHeight - 30
altitude = 0
aceleracao = 0
estadoDojogo = 0 -- 0 - vls na base 1 - vls fora dela 2 - game over
quantidadeDeExp = 0
expMinimo = 0
aceMinimo = 10
vls.x = display.contentCenterX
background.y = posicaoDofundo
fogo:setSequence("parado")
fogo2:setSequence("parado")
moviFogo = 0
fogo.rotation = 0
fogo2.rotation = 0
fumacaEsquerda = display.newImageRect("fumacaEsquerda.png",50,25)
fumacaEsquerda.x = 165
fumacaEsquerda.y = 470
fumacaEsquerda.xScale = 0.1
fumacaEsquerda.alpha = 0
fumacaDireita = display.newImageRect( "fumacaDireita.png",50,25)
fumacaDireita.x = 155
fumacaDireita.y = 470
fumacaDireita.xScale = 0.1
fumacaDireita.alpha = 0
iconis[1].x = posicaoHorizontalIconis()
iconis[1].y = posicaoVerticalIconis()
sequence(iconis[1])
iconis[1].objType = "1"
contador3 = 0
contador4 = 0
contador2 = 0
contador22 = 0
iconis[2].x = posicaoHorizontalIconis()
iconis[2].y = posicaoVerticalIconis()
sequence(iconis[2])
iconis[2].objType = "2"
iconis[3].x = posicaoHorizontalIconis()
iconis[3].y = posicaoVerticalIconis()
sequence(iconis[3])
iconis[3].objType = "3"
iconis[4].x = posicaoHorizontalIconis()
iconis[4].y = posicaoVerticalIconis()
sequence(iconis[4])
iconis[4].objType = "4"
textoAceleracao2.alpha = 0
textoAltitude2.alpha = 0
textoQuantidadeDeExp2.alpha = 0
audio.stop(exploChannel)
aux = 0
end
if e.phase == "moved" and e.x > vls.x-50 and e.x < vls.x + 50 then
if vls.x > e.x then
vls.rotation = -3
fogo.rotation = -4
fogo2.rotation = -4
moviFogo = 3
end
if vls.x < e.x then
vls.rotation = 3
fogo.rotation = 4
fogo2.rotation = 4
moviFogo = -3
end
if vls.x == e.x then
vls.rotation = 0
fogo.rotation = 0
fogo2.rotation = 0
moviFogo = 0
end
vls.x = e.x
end
if e.phase == "ended" then
vls.rotation = 0
moviFogo = 0
fogo.rotation = 0
fogo2.rotation = 0
-- duplo toque
if estadoDojogo == 2 then
aux = aux + 1
end
end
end
end
--painel
local painel2 = display.newImage("painel2.png",159.6,220)
painel2.width = 380
painel2.height = 450
local alert = display.newImage("alert.png",0,0)
alert.width = 50
alert.height = 50
alert.xScale = 0.1
alert.yScale = 0.1
function mostrarAlerta(x)
if x == 1 then
alert.x = 295
alert.y = 175
alert.rotation = -4
else
alert.x = 25
alert.y = 175
alert.rotation = 4
end
transition.to(alert,{time = 1000, xScale = 0.5, yScale = 0.5, onComplete = function ()
transition.to(alert,{time = 1000, xScale = 0.1, yScale = 0.1})
-- body
end})
end
local textoAltitude = display.newText(altitude,w*.509,48,native.systemFont,30)
local textoAceleracao = display.newText(aceleracao,w*.922,116,native.systemFont,30)
textoAceleracao.rotation = -4
local textoQuantidadeDeExp = display.newText(quantidadeDeExp,w*.089,116,native.systemFont,30)
textoQuantidadeDeExp.rotation = 4
local textoExpMinimo = display.newText(expMinimo,w*.070,227,native.systemFont,30)
textoExpMinimo.rotation = 4
local textoAceMinimo = display.newText(aceMinimo,w*.94,227,native.systemFont,30)
textoAceMinimo.rotation = -4
local buttons = {}
buttons[1] = display.newImage("bAcelerar.png")
buttons[1].width = 40
buttons[1].height = 60
buttons[1].x = w - buttons[1].contentWidth * .50
buttons[1].y = 305
buttons[1].myName = "acelerar"
buttons[1].rotation = 0
buttons[2] = display.newImage("bFrear.png")
buttons[2].width = 40
buttons[2].height = 60
buttons[2].x = 0 + buttons[1].contentWidth * .50
buttons[2].y = 305
buttons[2].myName = "frear"
buttons[2].rotation = 0
local j=1
for j=1, #buttons do
buttons[j]:addEventListener("touch", touchFunction)
end
vls:addEventListener("touch", touchFunction)
background:addEventListener("touch", touchFunction)
local alertaPainel0 = display.newImage("alertPainel0.png")
alertaPainel0.x = 244
alertaPainel0.y = 56.4
alertaPainel0.width = 47.3
alertaPainel0.height = 25
alertaPainel0.isVisible = true
local alertaPainel1 = display.newImage("alertPainel1.png")
alertaPainel1.x = 244
alertaPainel1.y = 56.4
alertaPainel1.width = 47.3
alertaPainel1.height = 25
alertaPainel1.isVisible = false
local function verificandoAlertaPainel( ... )
if estadoAlerta == 1 then
alertaPainel1.isVisible = true
alertaPainel0.isVisible = false
else
alertaPainel1.isVisible = false
alertaPainel0.isVisible = true
end
end
local function replicacao(i)
-- body
iconis[i].y = posicaoVerticalIconis()
iconis[i].x = posicaoHorizontalIconis()
sequence(iconis[i])
end
local function sensorCollide( self, event )
if "began" == event.phase then
if event.other.myName == "experiencia" then
quantidadeDeExp = quantidadeDeExp + 1
end
if event.other.myName == "dinheiro" then
quantidadeDeExp = quantidadeDeExp - 2
end
end
if event.other.objType == "1" then
transition.to(iconis[1],{time = 1 , y = 800 , transition = easing.inExpo})
end
if event.other.objType == "2" then
transition.to(iconis[2],{time = 1 , y = 800 , transition = easing.inExpo})
end
if event.other.objType == "3" then
transition.to(iconis[3],{time = 1 , y = 800 , transition = easing.inExpo})
end
if event.other.objType == "4" then
transition.to(iconis[4],{time = 1 , y = 800 , transition = easing.inExpo})
end
end
local explo = audio.loadStream( "Explo.mp3" )
local exploChannel
function verificandoValoresMinimos()
--verificando valores minimmos
if aceMinimo > aceleracao and estadoDojogo == 1 then
contador3 = contador3 + 1
estadoAlerta = 1
mostrarAlerta(1)
if contador3 == 3 then
exploChannel = audio.play( explo , { channel=4, loops=0, fadein= 0 } )
iconis[1]:pause()
iconis[2]:pause()
iconis[3]:pause()
iconis[4]:pause()
fogo:pause()
fogo2:pause()
estadoDojogo = 2
gamerover.alpha = 1
audio.stop(nasaiChannel)
audio.stop(nasarChannel)
textoAceleracao2.text = aceleracao
textoAltitude2.text = altitude
textoQuantidadeDeExp2.text = quantidadeDeExp
textoAceleracao2.alpha = 1
textoAltitude2.alpha = 1
textoQuantidadeDeExp2.alpha = 1
end
elseif contador4 == 0 then
contador3 = 0
estadoAlerta = 0
alert.x = -50
alert.y = -50
end
if expMinimo > quantidadeDeExp and estadoDojogo == 1 then
contador4 = contador4 + 1
estadoAlerta = 1
mostrarAlerta(2)
if contador4 == 3 then
exploChannel = audio.play( explo , { channel=4, loops=0, fadein= 0 } )
iconis[1]:pause()
iconis[2]:pause()
iconis[3]:pause()
iconis[4]:pause()
estadoDojogo = 2
gamerover.alpha = 1
audio.stop(nasaiChannel)
audio.stop(nasarChannel)
textoAceleracao2.text = aceleracao
textoAltitude2.text = altitude
textoQuantidadeDeExp2.text = quantidadeDeExp
textoAceleracao2.alpha = 1
textoAltitude2.alpha = 1
textoQuantidadeDeExp2.alpha = 1
end
elseif contador3 == 0 then
contador4 = 0
estadoAlerta = 0
alert.x = -40
alert.y = -40
end
-- body
end
-- Associate collision handler function with character
vls.collision = sensorCollide
vls:addEventListener( "collision" )
local ajuda = posicaoVerticalVls
local contador = 0
local contador3 = 0
local auxAceMinimo = 1
local auxExpMinimo = 1
timer.performWithDelay( 2000, verificandoValoresMinimos , 0 )
local update = function()
if estadoDojogo == 2 then
contador2 = 0
else
if altitude > 3000 then
final2.y =final2.y + 0.5
final.y =final.y + 0.2
vls.y = vls.y - 0.1
iconis[1].x = -210
iconis[2].x = -210
iconis[3].x = -210
iconis[4].x = -210
estadoDojogo = 66
if final.y > 138 then
final.y =final.y - 0.2
end
if final2.y > 438 then
final2.y =final2.y - 0.5
end
end
verificandoAlertaPainel()
--mostrando na tela textos atualizados
textoAltitude.text = altitude
textoAceleracao.text = aceleracao
textoQuantidadeDeExp.text = quantidadeDeExp
textoExpMinimo.text = expMinimo
textoAceMinimo.text = aceMinimo
iconis[1]:play() --executa a animação, é necessário usar essa função para ativar a animação
iconis[2]:play()
iconis[3]:play() --executa a animação, é necessário usar essa função para ativar a animação
iconis[4]:play()
if estadoDojogo == 0 then
vls.x = display.contentCenterX
vls.rotation = 0
end
-- incrementando a altitude do foguete
if estadoDojogo ~= 0 then
contador = contador + movimentoDeFundo
end
if posicaoVerticalVls <= ajuda and estadoDojogo == 1 then
if contador > 10 then
altitude = altitude + 1
auxAceMinimo = auxAceMinimo + 1
auxExpMinimo = auxExpMinimo + 1
contador = 0
end
ajuda = posicaoVerticalVls
elseif posicaoVerticalVls > ajuda and estadoDojogo ~= 0 then
if contador > 10 then
altitude = altitude + 1
auxAceMinimo = auxAceMinimo + 1
auxExpMinimo = auxExpMinimo + 1
contador = 0
end
ajuda = posicaoVerticalVls
end
--incrementando a aceleraçao minimo
if auxAceMinimo >= 50 and aceMinimo <= 100 then
contador2 = contador2 + 1
if contador2 <= 3 then
aceMinimo = aceMinimo + 5
else
aceMinimo = aceMinimo + 1
end
auxAceMinimo = 0
end
--incrementando a exp minimo
if auxExpMinimo >= 100 and expMinimo < 100 then
contador22 = contador22 + 1
if contador2 <= 2 then
expMinimo = expMinimo + 0
elseif contador2 <= 4 then
expMinimo = expMinimo + 1
else
expMinimo = expMinimo + 2
end
auxExpMinimo = 0
end
if estadoDaMovimentacao == 0 then
if posicaoDofundo < 1400 then
posicaoDofundo = posicaoDofundo + movimentoDeFundo
end
iconis[1].y = iconis[1].y + movimentoDeFundo
iconis[2].y = iconis[2].y + movimentoDeFundo
iconis[3].y = iconis[3].y + movimentoDeFundo
iconis[4].y = iconis[4].y + movimentoDeFundo
background.y = posicaoDofundo
end
if estadoDaMovimentacao == 1 then
posicaoVerticalVls = posicaoVerticalVls + vlsMovimentacaoVertical
vls.y = posicaoVerticalVls
end
if posicaoVerticalVls <= h*0.7 then
estadoDaMovimentacao = 0
end
if posicaoVerticalVls > h*0.7 then
estadoDaMovimentacao = 1
end
-- analisando se algum iconi saiu da tela
local j = 1
for j=1, #iconis do
if iconis[j].y > h + 30 then
replicacao(j)
end
end
fogo.x = vls.x - 11 + moviFogo
fogo.y = vls.y + 47
fogo2.x = vls.x + 10 + moviFogo
fogo2.y = vls.y + 47
if fumacaDireita.e == 1 then
transition.to(fumacaEsquerda,{time = 4500, alpha = 0 })
transition.to(fumacaDireita,{time = 4500, alpha = 0})
fumacaDireita.e = 0
end
end
end
Runtime:addEventListener("enterFrame", update)-----------------------------------------------------------------------------------------
end
-- show()
function scene:show( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
-- Code here runs when the scene is still off screen (but is about to come on screen)
elseif ( phase == "did" ) then
-- Code here runs when the scene is entirely on screen
end
end
-- hide()
function scene:hide( event )
local sceneGroup = self.view
local phase = event.phase
if ( phase == "will" ) then
-- Code here runs when the scene is on screen (but is about to go off screen)
elseif ( phase == "did" ) then
-- Code here runs immediately after the scene goes entirely off screen
end
end
-- destroy()
function scene:destroy( event )
local sceneGroup = self.view
-- Code here runs prior to the removal of scene's view
end
-- -----------------------------------------------------------------------------------
-- Scene event function listeners
-- -----------------------------------------------------------------------------------
scene:addEventListener( "create", scene )
scene:addEventListener( "show", scene )
scene:addEventListener( "hide", scene )
scene:addEventListener( "destroy", scene )
-- -----------------------------------------------------------------------------------
return scene