Skip to content
Snippets Groups Projects
Commit 962e8a75 authored by lukasWoyke's avatar lukasWoyke
Browse files

Merge remote-tracking branch 'origin/master' into 65-bug-fix-tries-lukas

parents 7113690d 2ec58114
Branches
No related tags found
3 merge requests!60Code cleanup lukas fix,!55Code cleanup lukas,!53Resolve "bugs"
Showing
with 44 additions and 129 deletions
{
"images" : [
{
"filename" : "grapButtonRightOn.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "grapButtonRightOn@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "grapButtonRightOn@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "joystick.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "joystick@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "joystick@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
Better Together/Better Together/Assets.xcassets/joystick.imageset/joystick.png

7.68 KiB

{
"images" : [
{
"filename" : "memory-difficulty-easy-unselected.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "memory-difficulty-easy-unselected@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "memory-difficulty-easy-unselected@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -17,6 +17,19 @@
<rect key="frame" x="0.0" y="0.0" width="896" height="414"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="pRO-Kt-eff">
<rect key="frame" x="753" y="54" width="32" height="32"/>
<color key="backgroundColor" red="1" green="0.99998801950000005" blue="1" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<constraints>
<constraint firstAttribute="height" constant="32" id="dd6-1n-zir"/>
<constraint firstAttribute="width" secondItem="pRO-Kt-eff" secondAttribute="height" multiplier="1:1" id="kEp-lk-53V"/>
</constraints>
<color key="tintColor" red="0.2357714772" green="0.28487256170000003" blue="0.36079549789999998" alpha="1" colorSpace="custom" customColorSpace="displayP3"/>
<state key="normal" image="gyroscope" catalog="system"/>
<connections>
<action selector="gyroscopeTapped:" destination="BV1-FR-VrT" eventType="touchUpInside" id="1RD-hh-5b6"/>
</connections>
</button>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="0UE-pO-cfO">
<rect key="frame" x="800" y="54" width="32" height="32"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
......@@ -45,12 +58,15 @@
<constraint firstItem="pdu-Ii-8P6" firstAttribute="top" secondItem="3se-qz-xqx" secondAttribute="top" id="Nsu-AA-bF7"/>
<constraint firstAttribute="bottom" secondItem="pdu-Ii-8P6" secondAttribute="bottom" id="O1A-JQ-T0f"/>
<constraint firstItem="0UE-pO-cfO" firstAttribute="top" secondItem="4qk-I5-YsI" secondAttribute="top" constant="10" id="fxt-0p-xa2"/>
<constraint firstItem="0UE-pO-cfO" firstAttribute="leading" secondItem="pRO-Kt-eff" secondAttribute="trailing" constant="15" id="qMe-qp-PqN"/>
<constraint firstItem="pRO-Kt-eff" firstAttribute="top" secondItem="4qk-I5-YsI" secondAttribute="top" constant="10" id="s4V-tW-zgi"/>
<constraint firstItem="4qk-I5-YsI" firstAttribute="trailing" secondItem="0UE-pO-cfO" secondAttribute="trailing" constant="20" id="xYS-kU-VYM"/>
</constraints>
</view>
<navigationItem key="navigationItem" largeTitleDisplayMode="never" id="Exl-IJ-XA8"/>
<connections>
<outlet property="exitButton" destination="0UE-pO-cfO" id="65D-VI-E7S"/>
<outlet property="gyroscopeButton" destination="pRO-Kt-eff" id="Gdn-nB-iL6"/>
<outlet property="spinnerView" destination="pdu-Ii-8P6" id="5eW-0b-MsP"/>
<segue destination="lE5-fW-SrJ" kind="unwind" identifier="unwindToMenu" unwindAction="unwind:" id="4uI-0a-5wj"/>
</connections>
......@@ -456,6 +472,7 @@
<image name="button_singleplay" width="1536" height="1024"/>
<image name="button_teamplay" width="1536" height="1024"/>
<image name="button_tutorial" width="1536" height="1024"/>
<image name="gyroscope" catalog="system" width="128" height="121"/>
<image name="xmark.circle.fill" catalog="system" width="128" height="121"/>
<systemColor name="systemBackgroundColor">
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
......
......
//
// FeedbackController.swift
// Better Together
//
// Created by Lukas Woyke on 26.01.21.
//
import UIKit
class FeedbackController {
// Combines sound and haptic feedback (and maybe as well sending and receiving things)
}
......@@ -99,10 +99,13 @@ class GameGyroscopeController {
private var initialZ: Double = 0.0
private var initialY: Double = 0.0
private var initialX: Double = 0.0
private var initalOrientation: UIDeviceOrientation? = nil
private var initialTimeStamp: Date? = nil
/// Caclulates the vector for controlling the character, by using the input
private func calculateAccVector(newAcc: SIMD3<Double>) -> CGVector {
checkReorientation()
// Sets the initial position, with the first reading attempt.
if resetOrientationActive {
initialZ = newAcc.z
......@@ -115,7 +118,7 @@ class GameGyroscopeController {
var dx = -(newAcc.y - initialY)
var dy = newAcc.x - initialX
// Adjust movement when user olds device in LandscapeRight orientation.
if newAcc.x > 0 {
dx *= (-1)
......@@ -129,4 +132,22 @@ class GameGyroscopeController {
return vector
}
// If user holds device longer then 10 seconds in another oreintation reset the inial values.
private func checkReorientation() {
if initialTimeStamp == nil || initalOrientation == nil {
initialTimeStamp = Date()
initalOrientation = UIDevice.current.orientation
}
if initalOrientation != UIDevice.current.orientation {
let interval = Date().timeIntervalSince(initialTimeStamp!)
if interval > 8 {
resetOrientation()
initalOrientation = UIDevice.current.orientation
}
} else {
initialTimeStamp = Date()
}
}
}
......@@ -11,21 +11,23 @@ import CoreHaptics
class HapticResponseController {
// Feedback for grabbing.
static func openGrabFeedback() {
// MARK: - TODO: Remove the function if it is not used in any place
let generator = UIImpactFeedbackGenerator(style: .medium)
generator.impactOccurred()
}
static func grabNotSucceedFeedback() {
// MARK: - TODO: The function name should be changed according to its usage
let generator = UIImpactFeedbackGenerator(style: .rigid)
generator.impactOccurred()
}
static func grabSucceedFeedback() {
// Maybe use here another feedback here, like UISelectionFeedbackGenerator
let generator = UIImpactFeedbackGenerator(style: .light)
generator.impactOccurred()
}
static func simpleFallDownFeedback() {
// MARK: - TODO: Remove the function if it is not used in any place
let generator = UIImpactFeedbackGenerator(style: .heavy)
generator.impactOccurred()
}
......
......
//
// SoundFeedbackConrtoller.swift
// Better Together
//
// Created by Lukas Woyke on 26.01.21.
//
import AVKit
class SoundFeedbackController {
static var sharedInstance:SoundFeedbackController = SoundFeedbackController()
private var soundPlayer: AVAudioPlayer?
private var volumn: Float = 0.3
enum EffectType {
case grab
case drop
}
func play(effectType: EffectType) {
soundPlayer?.stop()
switch effectType {
case .grab:
soundPlayer = try? AVAudioPlayer(soundFileName: "audio_grab", fileExtension: "mp3")
case .drop:
soundPlayer = try? AVAudioPlayer(soundFileName: "audio_drop", fileExtension: "mp3")
}
soundPlayer?.volume = volumn
soundPlayer?.play()
}
}
extension AVAudioPlayer {
public convenience init(soundFileName: String, fileExtension: String) throws {
guard let url = Bundle.main.url(forResource: soundFileName, withExtension: fileExtension) else { fatalError("Soundfile cannot be found") }
try self.init(contentsOf: url)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment