Skip to content

Commit

Permalink
Merge pull request #59 from keisukeYamagishi/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
keisukeYamagishi authored Jan 5, 2024
2 parents 078010b + c189110 commit b224f88
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 11 deletions.
12 changes: 12 additions & 0 deletions Tetris.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
9095E5B22A4291D900BD97F1 /* TetrisUnitTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9095E5B12A4291D900BD97F1 /* TetrisUnitTest.swift */; };
9095E5B92A4297CA00BD97F1 /* TetrisBarTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9095E5B82A4297CA00BD97F1 /* TetrisBarTest.swift */; };
9097CC952B37C1970076784A /* acknowtt.ttf in Resources */ = {isa = PBXBuildFile; fileRef = 9097CC942B37C1970076784A /* acknowtt.ttf */; };
909E58732B47A46D00AD8805 /* Animation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 909E58722B47A46D00AD8805 /* Animation.swift */; };
90AA74382B3EF85100304F8A /* Asset.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 90AA74372B3EF85100304F8A /* Asset.xcassets */; };
C791D7D81FE6205E00983F80 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = F0B335691F0E517100A8F6DF /* AppDelegate.swift */; };
F0B335741F0E517200A8F6DF /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F0B335721F0E517200A8F6DF /* LaunchScreen.storyboard */; };
Expand Down Expand Up @@ -83,6 +84,7 @@
9095E5B12A4291D900BD97F1 /* TetrisUnitTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TetrisUnitTest.swift; sourceTree = "<group>"; };
9095E5B82A4297CA00BD97F1 /* TetrisBarTest.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TetrisBarTest.swift; sourceTree = "<group>"; };
9097CC942B37C1970076784A /* acknowtt.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; path = acknowtt.ttf; sourceTree = "<group>"; };
909E58722B47A46D00AD8805 /* Animation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Animation.swift; sourceTree = "<group>"; };
90AA74372B3EF85100304F8A /* Asset.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Asset.xcassets; sourceTree = "<group>"; };
F0B335661F0E517100A8F6DF /* Tetris.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Tetris.app; sourceTree = BUILT_PRODUCTS_DIR; };
F0B335691F0E517100A8F6DF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -161,6 +163,7 @@
900064742A447513008B7CF9 /* View */ = {
isa = PBXGroup;
children = (
909E58712B47A45F00AD8805 /* Animate */,
900064772A447513008B7CF9 /* View */,
9000647B2A447513008B7CF9 /* ViewController */,
);
Expand Down Expand Up @@ -215,6 +218,14 @@
path = TetrisUnitTest;
sourceTree = "<group>";
};
909E58712B47A45F00AD8805 /* Animate */ = {
isa = PBXGroup;
children = (
909E58722B47A46D00AD8805 /* Animation.swift */,
);
path = Animate;
sourceTree = "<group>";
};
F0B3355D1F0E517000A8F6DF = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -378,6 +389,7 @@
900064732A44750B008B7CF9 /* Cp.swift in Sources */,
900064812A447513008B7CF9 /* FieldView.swift in Sources */,
900064802A447513008B7CF9 /* Bar.swift in Sources */,
909E58732B47A46D00AD8805 /* Animation.swift in Sources */,
9000646B2A44750A008B7CF9 /* Level.swift in Sources */,
C791D7D81FE6205E00983F80 /* AppDelegate.swift in Sources */,
900064702A44750B008B7CF9 /* Bs.swift in Sources */,
Expand Down
10 changes: 5 additions & 5 deletions Tetris/Extention/UIView+.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ extension UIView {
UIView.animate(withDuration: 1.0,
delay: 1.0,
animations: { [self] in
alpha = 0.0
}, completion: { [self] _ in
alpha = 1.0
completion()
})
alpha = 0.0
}, completion: { [self] _ in
alpha = 1.0
completion()
})
}
}
2 changes: 1 addition & 1 deletion Tetris/Model/Component/Bars.swift
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ final class Bars {
}
}
}

var isBottom: Bool {
for tate in 0 ..< values.count {
for yoko in 0 ..< values[tate].count {
Expand Down
34 changes: 34 additions & 0 deletions Tetris/View/Animate/Animation.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
//
// Animation.swift
// Tetris
//
// Created by keisuke yamagishi on 2024/01/05.
// Copyright © 2024 shichimitoucarashi. All rights reserved.
//

import UIKit

final class Animation {
var count = 0
func flashAnimation(targetView: UIView,
repeatCount: Int,
_ completion: @escaping () -> Void)
{
targetView.alpha = 1.0
UIView.animate(withDuration: 0.2,
delay: 0.0,
animations: {
targetView.alpha = 0.0
}, completion: { [self] _ in
targetView.alpha = 1.0
count += 1
if repeatCount == count {
completion()
} else {
flashAnimation(targetView: targetView,
repeatCount: repeatCount,
completion)
}
})
}
}
7 changes: 4 additions & 3 deletions Tetris/View/View/FieldView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import UIKit

final class FieldView: UIView {

var barSize: CGFloat {
frame.height / CGFloat(Tate)
}
Expand Down Expand Up @@ -49,7 +48,8 @@ final class FieldView: UIView {
}

func animation(bars: [[Bs]],
completion: @escaping () -> Void) {
completion: @escaping () -> Void)
{
var tag = 1
var willAnimation = 0
var didAnimation = 0
Expand All @@ -59,7 +59,8 @@ final class FieldView: UIView {
if isBar[yoko].status == .animation {
willAnimation += 1
let bar = viewWithTag(tag) as! Bar
bar.flashAnimation {
let animation = Animation()
animation.flashAnimation(targetView: bar, repeatCount: 3) {
didAnimation += 1
if willAnimation == didAnimation {
completion()
Expand Down
5 changes: 3 additions & 2 deletions Tetris/View/ViewController/Game/Tetris.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" text="Lv 1" textAlignment="right" lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="N6f-34-3CO">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" preservesSuperviewLayoutMargins="YES" text="Lv:9" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumScaleFactor="0.5" translatesAutoresizingMaskIntoConstraints="NO" id="N6f-34-3CO">
<rect key="frame" x="245" y="184" width="67" height="33"/>
<fontDescription key="fontDescription" name="AcknowledgeTTBRK" family="Acknowledge TT BRK" pointSize="37"/>
<nil key="textColor"/>
Expand Down Expand Up @@ -98,16 +98,17 @@
<constraint firstItem="Wio-x1-ADx" firstAttribute="leading" secondItem="SQK-Nc-t3v" secondAttribute="leading" constant="10" id="EQi-Qp-g2O"/>
<constraint firstItem="IZd-lt-khk" firstAttribute="leading" secondItem="7nT-xt-Rwc" secondAttribute="leading" id="EZO-3M-Xy9"/>
<constraint firstItem="JRF-82-wyS" firstAttribute="leading" secondItem="7nT-xt-Rwc" secondAttribute="leading" id="FUP-5s-995"/>
<constraint firstItem="SQK-Nc-t3v" firstAttribute="trailing" relation="greaterThanOrEqual" secondItem="N6f-34-3CO" secondAttribute="trailing" constant="3" id="JpW-L7-Th6"/>
<constraint firstItem="IZd-lt-khk" firstAttribute="leading" secondItem="ohk-fz-fI2" secondAttribute="leading" id="UjV-Rx-nyJ"/>
<constraint firstItem="IZd-lt-khk" firstAttribute="top" secondItem="JRF-82-wyS" secondAttribute="bottom" constant="20" id="VFg-SA-6ec"/>
<constraint firstItem="7nT-xt-Rwc" firstAttribute="leading" secondItem="ohk-fz-fI2" secondAttribute="leading" id="XQu-Yf-vG5"/>
<constraint firstItem="N6f-34-3CO" firstAttribute="leading" secondItem="ohk-fz-fI2" secondAttribute="leading" id="YhS-Sz-qcf"/>
<constraint firstItem="N6f-34-3CO" firstAttribute="top" secondItem="ohk-fz-fI2" secondAttribute="bottom" constant="30" id="dWa-Hk-pfp"/>
<constraint firstItem="SQK-Nc-t3v" firstAttribute="bottom" secondItem="IZd-lt-khk" secondAttribute="bottom" constant="14" id="gBr-Ce-8O4"/>
<constraint firstItem="JRF-82-wyS" firstAttribute="leading" secondItem="ohk-fz-fI2" secondAttribute="leading" id="kJb-5y-Ihy"/>
<constraint firstItem="ohk-fz-fI2" firstAttribute="leading" secondItem="Wio-x1-ADx" secondAttribute="trailing" constant="5" id="kNg-HN-nPr"/>
<constraint firstItem="ohk-fz-fI2" firstAttribute="trailing" secondItem="Nim-Kk-5tD" secondAttribute="trailing" id="pZg-3f-9PH"/>
<constraint firstItem="SQK-Nc-t3v" firstAttribute="trailing" secondItem="Nim-Kk-5tD" secondAttribute="trailing" constant="1" id="saU-r5-sUw"/>
<constraint firstItem="N6f-34-3CO" firstAttribute="leading" secondItem="Wio-x1-ADx" secondAttribute="trailing" constant="5" id="tTo-FA-EAY"/>
<constraint firstItem="JRF-82-wyS" firstAttribute="top" secondItem="7nT-xt-Rwc" secondAttribute="bottom" constant="20" id="uVu-Kk-PB2"/>
<constraint firstItem="Wio-x1-ADx" firstAttribute="top" secondItem="Nim-Kk-5tD" secondAttribute="bottom" constant="38.5" id="yn0-yb-mH9"/>
<constraint firstItem="SQK-Nc-t3v" firstAttribute="bottom" secondItem="Wio-x1-ADx" secondAttribute="bottom" constant="10" id="zhb-v2-ZGs"/>
Expand Down
Binary file modified doc/Tetris.mov.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit b224f88

Please sign in to comment.