-
Notifications
You must be signed in to change notification settings - Fork 116
Expand file tree
/
Copy pathCommandLineGameIntro.swift
More file actions
25 lines (21 loc) · 969 Bytes
/
CommandLineGameIntro.swift
File metadata and controls
25 lines (21 loc) · 969 Bytes
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
//
// main.swift
//
// Created by David Rifkin on 7/12/19.
// Copyright © 2019 David Rifkin. All rights reserved.
//
import Foundation
//this prints something out in command line and then waits for the user to give an input
func getInput() -> String? {
print("get input:", terminator: " ")
let lineIn = readLine()
return lineIn
}
// this would save the value of the input
// var thisWasInput = getInput()
// when we call this function, it creates a loop that will run all of our game logic. What kind of loop could we use inside of it? Be careful not to create an infinite loop!
func gameLoop() {
// we could call getInput to print things out and get an input value. Remember what Type we get as the return value for our input function
let input = getInput()
// we could also create some other functions to handle the other parts of our game, like seeing if the game is over, seeing if the user won or lost, and some other stuff too!
}