Skip to content

Instantly share code, notes, and snippets.

View dopefaceee's full-sized avatar
🟢
Focusing not to work hard.

Ade Suluh N. dopefaceee

🟢
Focusing not to work hard.
View GitHub Profile
import 'dart:io';
import 'package:flutter/material.dart';
void main() => runApp(MaterialApp(home: MyApp()));
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
const value1 = 5;
//const b = DateTime.now(); ---> error
//const value2;
//value2 = 10 ---> harus diinisiasi pada baris yg sama
Class A {
static const a = 5;
// const a = 5; ---> error karena tidak bisa sebagai intance variable
final a, b;
// Controls auto save of dirty files. Read more about autosave [here](https://code.visualstudio.com/docs/editor/codebasics#_save-auto-save).
// - off: A dirty file is never automatically saved.
// - afterDelay: A dirty file is automatically saved after the configured `files.autoSaveDelay`.
// - onFocusChange: A dirty file is automatically saved when the editor loses focus.
// - onWindowChange: A dirty file is automatically saved when the window loses focus.
"files.autoSave": "off",
// Controls the font size in pixels.
@dopefaceee
dopefaceee / dart_stream.dart
Created August 14, 2018 14:09
Using Stream with Cake Factory Analogy
import 'dart:async';
class Cake {}
class Order {
String type;
Order(this.type);
}
void main() {
final controller = StreamController();
@dopefaceee
dopefaceee / pathfinding.swift
Created September 15, 2017 13:33
PathFinding AI
// Convert node physics bodies into GKPolygonObstacles.
let obstacles = SKNode.obstaclesFromNodePhysicsBodies(self["//obstacles"])
// Construct a GKObstacleGraph.
let graph = GKObstacleGraph(obstacles: obstacles, bufferRadius: 30.0)
// Connect the TaskBot and PlayerBot via their positions.
let startNode = graph.connectNodeUsingObstacles(taskBot.position) let endNode = graph.connectNodeUsingObstacles(playerBot.position)
// Find the path.
let pathNodes = graph.findPathFromNode(startNode,
toNode: endNode) as! [GKGraphNode2D]
@dopefaceee
dopefaceee / agents.swift
Created September 15, 2017 13:30
Agents, Goals, and Behaviors
/* Make some goals, we want to seek the enemy, avoid obstacles, target speed */
GKGoal *seek = [GKGoal goalToSeekAgent:enemyAgent];
GKGoal *avoid = [GKGoal goalToAvoidObstacles:obstacles];
GKGoal *targetSpeed = [GKGoal goalToReachTargetSpeed:50.0f];
/* Combine goals into behavior
GKBehavior *behavior = [GKBehavior behaviorWithGoals:@[seek,avoid,targetSpeed]
andWeights:@[@1.0,@5.0,@0.5]];
/* Make an agent - add the behavior to it */
GKAgent2D *agent = [[GKAgent2D* alloc] init];
agent.behavior = behavior;
@dopefaceee
dopefaceee / shader.cpp
Created September 15, 2017 13:10
Metal Shader Declaration
#include <metal_stdlib>
using namespace metal; #include <SceneKit/scn_metal>
struct custom_vertex_t {
float3 position [[attribute(SCNVertexSemanticPosition)]];
};
struct custom_node_t {
float4x4 modelViewProjectionTransform;
};
struct MyStruct {
float3 direction;