This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#HSV形式からRGB形式に変換 | |
#R=0 ~ 255, G=0 ~ 255, B=0 ~ 255, | |
def hsv_to_rgb(h,s,v): | |
# h = 0 ~ 360 | |
# s = 0 ~ 255 | |
# v = 0 ~ 255 | |
i = int(h / 60.0) | |
mx = v | |
mn = v - ((s / 255.0) * v) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// String→Int | |
var s:String = "a" | |
print(Int(s,radix:2)!) // error | |
print(Int(s,radix:8)!) // error | |
print(Int(s,radix:10)!) // error | |
print(Int(s,radix:16)!) // 16 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Int→String | |
var i:Int = 10 | |
print(String(i,radix:2)) // 1010 | |
print(String(i,radix:8)) // 12 | |
print(String(i,radix:10)) // 10 | |
print(String(i,radix:16)) // a | |
// String→Int | |
var s:String = "10" | |
print(Int(s,radix:2)!) // 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#if arch(i386) || arch(x86_64) | |
// シミュレーターでのみ実行★ | |
let speed:CGFloat = 10.0 | |
let jump:CGFloat = 25.0 | |
#else | |
// 実機でのみ実行★ | |
let speed:CGFloat = 5.0 | |
let jump:CGFloat = 15.0 | |
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 変数準備 | |
var a:Int = 1 | |
// 最初はaに1が入る | |
print(a) // a=1 | |
// 引数にinoutを付けると関数内で値を変えられる | |
func cvalue(inout a:Int) { | |
a = 0 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 設定ファイルを読み込み | |
let filePath = NSBundle.mainBundle().pathForResource("BarInfo.plist", ofType: nil) | |
let infoList = NSMutableDictionary(contentsOfFile: filePath!) | |
let X = infoList!.valueForKeyPath("Offset.X")! as! Int | |
let Y = infoList!.valueForKeyPath("Offset.Y")! as! Int | |
let Width = infoList!.valueForKeyPath("Size.Width")! as! Int | |
let Height = infoList!.valueForKeyPath("Size.Height")! as! Int |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ① | |
// 自作クラス | |
class CommonData:NSObject,NSCoding { | |
var start: CGPoint! | |
var end: CGPoint! | |
// 初期値0 | |
override init() { | |
super.init() | |
setParam(CGPoint(x:0,y:0),e:CGPoint(x:0,y:0)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ① | |
enum itemLabel:String { | |
case name = "名前" | |
case price = "値段" | |
} | |
enum sectionLabel:String { | |
case vegetable = "野菜" | |
case meat = "肉" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var workArray:[[String]] = [ | |
[" "," "," "," "," "," "," "," "," "," "], | |
[" "," "," "," "," "," "," "," "," "," "], | |
[" "," "," "," "," "," "," "," "," "," "], | |
[" "," "," "," "," "," "," "," "," "," "], | |
[" ","○","●","●","○","●","●"," "," "," "], | |
[" "," "," "," ","●","○","●"," "," "," "], | |
[" "," "," "," "," "," ","●"," "," "," "], | |
[" "," "," "," "," "," "," "," "," "," "], | |
[" "," "," "," "," "," "," "," "," "," "], |