Skip to content

Commit

Permalink
TODO list
Browse files Browse the repository at this point in the history
  • Loading branch information
ybs1164 committed Aug 19, 2020
1 parent 10d7f1f commit 92450ea
Show file tree
Hide file tree
Showing 15 changed files with 68 additions and 70 deletions.
12 changes: 6 additions & 6 deletions dist/js/core.js

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ func serverWs(w http.ResponseWriter, r *http.Request) {
go client.ReadPump()
}

// TODO : Achievement
// TODO : GameSpeed
// TODO : GameMode

func main() {
runtime.GOMAXPROCS(runtime.NumCPU())
rand.Seed(time.Now().UnixNano())
Expand Down Expand Up @@ -96,7 +100,7 @@ func moveloop(ticker time.Ticker) { // manages the motion of all objects.
Y: o.Y - o.R,
W: o.R * 2,
H: o.R * 2,
}) { // 똑같은 오브젝트가 아니고, 죽지 않았으며, 이미 충돌감지가 처리되지 않았고, 주인이 같을 때 반동값을 주는가, 타 오브젝트의 주인이 자신의 오브젝트가 아닌가
}) {
if o != obj2 && !obj2.IsDead && !(o.IsCollision || obj2.IsCollision) && (obj2.Owner != o.Owner || obj2.IsOwnCol && o.IsOwnCol) && o != obj2.Owner && obj2 != o.Owner {
if (o.X-obj2.X)*(o.X-obj2.X)+(o.Y-obj2.Y)*(o.Y-obj2.Y) < (o.R+obj2.R)*(o.R+obj2.R) {
if o.Collision != nil {
Expand Down
2 changes: 2 additions & 0 deletions obj/area.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"encoding/binary"
)

// TODO : Area

var AreaList Area

type Area struct {
Expand Down
2 changes: 2 additions & 0 deletions obj/bullet.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
"math"
)

// TODO : Should fix object AI

func DefaultTrapTick(obj *Object) {
if lib.Now()-obj.SpawnTime > 3000 {
obj.IsOwnCol = false
Expand Down
1 change: 1 addition & 0 deletions obj/gun.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (obj *Object) Shot() {
obj.Dy -= math.Sin(obj.Dir+g.Dir) * 0.1 * g.GunBound
g.DelayTime = reloadtime
g.IsShot = true
// This command is Changing object's layer
if obj.Index == -1 { // as subObject
Objects[GunOwner.Index] = &bullet
GunOwner.Index = len(Objects)
Expand Down
30 changes: 11 additions & 19 deletions obj/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,8 @@ type Object struct {
Damage float64 `json:"damage"`
GetDH float64 `json:"getdh"` // get damage and health
Speed float64 `json:"speed"`
/*
바운드 값은 상대방을 밀어내는 정도,
스탠스 값은 자신이 밀쳐지는 정도를 뜻합니다.
바운드/ 스탠스 시스템은 하자가 있습니다.
연구 결과 데미지 값이 바운드/ 스탠스 값에 영향을 주는 사실을 발견했습니다.
따라서 바운드/ 스탠스 시스템은 데미지와 관련된 값으로 재설계가 필요합니다.
*/
// TODO : should fix bounce system
// TODO : should change json name "bound" to "bounce"
Bounce float64 `json:"bound"`
Stance float64 `json:"stance"`
Opacity float64 `json:"opacity"`
Expand All @@ -57,19 +52,16 @@ type Object struct {
DeadTime float64 `json:"deadTime"`

IsBorder bool `json:"isBorder"`
IsOwnCol bool `json:"isOwnCol"` // 부모 오브젝트와의 충돌감지가 되는가?
IsOwnCol bool `json:"isOwnCol"` // Can this object collision Owner object?
IsDead bool `json:"isDead"`
IsCollision bool `json:"isCollision"` // Is finished collision detect?
IsShot bool `json:"isShot"`
IsTargeted bool `json:"isTargeted"`
IsShowHealth bool `json:"isShowHealth"`
IsShowName bool `json:"isShowName"`
IsBack bool // 드론이 주인에게 돌아가야 하는가?
IsBack bool // Should drone object go back to Owner object?

/*
서브 오브젝트는 오브젝트에 붙어있는 오브젝트들입니다.
서브 오브젝트들은 히트박스, 체력값을 가지고 있지 않습니다.
*/
// SubObjects do not enable HitBox and Health.
SubObjects []*Object
HitObject *Object
Target *Object
Expand All @@ -81,13 +73,13 @@ type Object struct {

//
func (obj *Object) ObjectTick() {
obj.X += obj.Dx //* lib.GameSetting.GameSpeed // 좌표값에 속도 적용
obj.Y += obj.Dy //* lib.GameSetting.GameSpeed
obj.X += obj.Dx
obj.Y += obj.Dy

obj.Dx *= 0.97 //math.Pow(0.97, lib.GameSetting.GameSpeed) 감속 코드
obj.Dy *= 0.97 //math.Pow(0.97, lib.GameSetting.GameSpeed)
obj.Dx *= 0.97
obj.Dy *= 0.97

if obj.IsBorder { // 화면 밖으로 벗어나는가?
if obj.IsBorder {
if obj.X > lib.GameSetting.MapSize.X+lib.Grid*4 {
obj.X = lib.GameSetting.MapSize.X + lib.Grid*4
}
Expand Down Expand Up @@ -240,7 +232,7 @@ func (o *Object) SetController(p *Player) {
}

var objID = 1
var ObjIDList []int // 썼던 오브젝트 id 리스트. 재활용함.
var ObjIDList []int // Reuse obj's ID

func NewObject(value map[string]interface{}, t func(*Object), c func(*Object, *Object), k func(*Object, *Object), d func(*Object, *Object)) *Object {
ID := objID
Expand Down
1 change: 1 addition & 0 deletions obj/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ func (p *Player) ReadPump() {

}

// TODO : Stat System, Upgrade System
// Event Catch Message
func Event(p *Player, message []byte) {
ObjMutex.Lock()
Expand Down
4 changes: 3 additions & 1 deletion obj/shape.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

var ShapeCount int

// TODO : other Shape and Bosses
func AddShape() {
for ; ShapeCount > 0; ShapeCount-- {
Objects = append(Objects, NewObject(map[string]interface{}{
Expand All @@ -25,6 +26,7 @@ func AddShape() {
}
}

func DefaultShapeTick(o *Object) { // shape ai
// TODO : shape AI
func DefaultShapeTick(o *Object) {
o.Dir += 0.005
}
3 changes: 3 additions & 0 deletions obj/tank.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ func TankTick(obj *Object) {
}
}

// TODO : ChangeTank Method
func (o *Object) ChangeTank(c *Object) {
o.Type = c.Type
o.Bounce = c.Bounce
Expand All @@ -47,6 +48,7 @@ func (o *Object) ChangeTank(c *Object) {
o.DeadEvent = c.DeadEvent
}

// TODO : other Tank
func NewTank(t string) *Object {
var obj *Object = NewObject(map[string]interface{}{
"type": t,
Expand Down Expand Up @@ -630,6 +632,7 @@ func NewTank(t string) *Object {
o.R = o.Owner.R * 0.5
o.X = o.Owner.X
o.Y = o.Owner.Y
o.Dir = o.Owner.Dir
if o.Owner.H == 0 || o.Owner.IsDead == true {
o.IsDead = true
}
Expand Down
9 changes: 2 additions & 7 deletions src/js/data/gun.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@ import { drawC } from '../lib/draw';
export const Gun = function (paths, dir, color, isMoveDir, isStatic) {
'use strict';

/*
이 객체는 독단적으로 행동할 수 없습니다.
무조건 Obj 객체에 종속되어 있으며, 위치도 종속된 Obj 객체를 따릅니다.
*/

this.paths = paths;
this.dir = dir || 0;
this.color = color;
if (this.color == undefined) this.color = 1; // default gun color
this.isMoveDir = isMoveDir || 0; // is Cannot Control Gun? (and Turn like bolt?) (using Smasher or Spike)
this.isStatic = isStatic || false; // 총구가 가로로 늘어나지 않는가? (using Skimmer or Rocketeer 's Gun)
this.isStatic = isStatic || false; // Doesn't the muzzle stretch horizontally? (using Skimmer or Rocketeer 's Gun)
this.shotTime = []; // using gun's animation
this.back = 0;

Expand All @@ -35,7 +30,7 @@ export const Gun = function (paths, dir, color, isMoveDir, isStatic) {
}
}

this.SetCanvasSize = function (camera, size, pos, r, dir) { // 오브젝트를 이미지로 처리할 때,
this.SetCanvasSize = function (camera, size, pos, r, dir) {
if (this.isMoveDir) {
dir = 0;
}
Expand Down
39 changes: 19 additions & 20 deletions src/js/data/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ export const Obj = function(id) {
this.ctx = this.cv.getContext("2d");

/*
오브젝트에 총구가 존재할 때, 불투명하지 않다면 오브젝트를 이미지로 처리합니다.
(이 방법이 아닌 것 같다면, 다이피오에서 확인해보세요. 이 방법이 맞다고 단언할 수 있습니다.)
When an object has a gun, it is treated as an image if it is not opaque.
*/

this.hitTime = 0;
Expand All @@ -66,10 +65,10 @@ export const Obj = function(id) {
this.y = data.y;
if (system.playerSetting.id !== this.id) {
/*
만약 자신이 직접 조종하는 탱크라면, 클라이언트에서 직접 방향값을 정해줍니다.
그렇지 않다면 방향값을 보다 부드럽게 만들어줍니다.
다이피오에서는 직접 조종하는 탱크의 위치도 클라이언트에서 약간 처리해주는 것 같은데,
아직 그 부분은 구현되지 못했습니다.
If it's a self-controlled tank, the client sets the directional value.
Otherwise, it will make the directional value smoother.
I think the client handles the location of the direct-controlled tank a little bit.
That part has not been implemented yet.
*/
if (this.dir) {
let ccw = Math.cos(data.dir)*Math.sin(this.dir)-Math.sin(data.dir)*Math.cos(this.dir);
Expand Down Expand Up @@ -127,7 +126,7 @@ export const Obj = function(id) {
this.color = colorType(data.type,data.team);
};

this.DrawSet = function (camera) { // 그릴 때 중복되는 값들을 간결하게 보내줍니다.
this.DrawSet = function (camera) {
let c = colorList[this.color]; // get color value
if (this.hitTime > 60) { // hit effect
c = c.getLightRGB((this.hitTime - 60) / 70);
Expand All @@ -146,7 +145,7 @@ export const Obj = function(id) {
};
}

this.SetCanvasSize = function (camera) { // 오브젝트를 이미지로 처리할 때의 중복되는 값들을 간결하게 보내줍니다.
this.SetCanvasSize = function (camera) {
var {x, y, z, t, r, dir} = this.DrawSet(camera);
let rr = r * getPolygonRadius(Math.abs(getObjectPoint(t)));
var size = {x: rr * z * 2, y: rr * z * 2,};
Expand Down Expand Up @@ -267,12 +266,12 @@ export const Obj = function(id) {

this.DrawName = function (ctx, camera) {
/*
오브젝트의 이름과 점수를 그려주는 함수입니다.
아직 이 함수는 완벽하지 않습니다.
총 3가지가 불완전한데요,
하나는 레이어,
하나는 그리는 방식,
나머지 하나는 샌드박스 모드에서 치트를 사용할 때 이름의 색이 노란색으로 바뀌는 것입니다.
A function that draws the name and score of an object.
This function is not perfect yet.
Three things are incomplete in total.
One is layer,
One is the way to draw.
The other is that the name changes to yellow when you use the cheats in sandbox mode.
*/

ctx.save();
Expand Down Expand Up @@ -314,12 +313,12 @@ export const Obj = function(id) {

this.DrawHPBar = function(ctx, camera) {
/*
오브젝트의 체력바를 그려주는 함수입니다.
아직 이 함수는 완벽하지 않습니다.
총 3가지가 불완전한데요,
하나는 레이어,
하나는 체력 바의 애니메이션,
나머지 하나는 오브젝트의 크기나 종류에 따른 체력 바의 길이입니다.
Function that draws the object's physical strength bar.
This function is not perfect yet.
Three things are incomplete in total.
One is layer,
One is the animation of the fitness bar.
The other is the length of the fitness bar, depending on the size or type of object.
*/

let healthPercent = this.h/this.mh;
Expand Down
4 changes: 2 additions & 2 deletions src/js/data/ui/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@ import { RGB } from '../../lib/util';

export default class DefaultUI {
constructor(x, y, w, h, mx, my, c) {
this.x = x; // 여기에서 의미하는 xy 값은 절대 좌표값이 아니라 상대 좌표값을 의미합니다.
this.x = x;
this.y = y;
this.w = w || 0;
this.h = h || 0;
this.mx = mx || "mid"; // "left" "mid" "right" 상위 오브젝트에 대해 중심점을 잡아주는 역할을 해줍니다.
this.mx = mx || "mid"; // "left" "mid" "right"
this.my = my || "mid"; // "up" "mid" "down"
this.color = c;
this.childs = [];
Expand Down
4 changes: 0 additions & 4 deletions src/js/lib/draw.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { backgroundColor, minimapBackgroundColor, minimapBorderColor } from '../data/console'
import { RGB, getPolygonRadius, getObjectPoint } from './util';

/*
전체적인 그래픽을 담당하고 있는 파일입니다.
*/

export const drawCircle = function (ctx, x, y, z, r) {
ctx.beginPath();
ctx.arc(x * z, y * z,r * z, 0, Math.PI * 2);
Expand Down
7 changes: 4 additions & 3 deletions src/js/lib/util.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { Gun } from '../data/gun.js';

export const RGB = function(r, g, b) {
/*
store the color information as RGB code
*/
// store the color information as RGB code
this.r;
this.g;
this.b;
Expand Down Expand Up @@ -107,6 +105,7 @@ export const calByte = { // string's byte calculation functions
}
}; // https://zzznara2.tistory.com/458

// TODO : fix this func
export const getPolygonRadius = function (p) {
if (p === 0) return 1; // circle
return Math.sqrt(Math.PI / (Math.sin(Math.PI / p) * Math.cos(Math.PI / p) * p)); // polygon
Expand All @@ -118,6 +117,7 @@ export const getObjectPoint = function (type) {
case "Trap":
return -3;
case "Triangle":
case "TriangleGun":
case "Drone":
case "DropperBullet":
return 3;
Expand Down Expand Up @@ -182,6 +182,7 @@ export const colorType = function(type, team){
}
}

// TODO : FINISH THIS.
export const gunList = { // Returns the width of a given text typed.
"AutoGun":[
new Gun([[0.6,0],[0.6,2],[-0.6,2],[-0.6, 0]]),
Expand Down
14 changes: 7 additions & 7 deletions src/js/system.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { drawBackground, drawText } from './lib/draw';
import { RGB, calByte } from './lib/util';
let socket;

/*
/* TODO :
This file is responsible for the entire gaming system.
overall codes are like spaghetti..
*/
Expand Down Expand Up @@ -461,11 +461,6 @@ export default class System {
}

this.ctx.clearRect(0,0,this.cv.width,this.cv.height); // clear canvas

if (this.gameSetting.isConnecting) { // connecting text
this.textinputanime = 1;
this.connectinga = Math.min(this.connectinga + 0.01 * tick,1);
}

if (this.gameSetting.isGaming) {
drawBackground(this.ctx, this.camera.x, this.camera.y, this.camera.z, this.cv.width, this.cv.height, this.area);
Expand Down Expand Up @@ -519,13 +514,18 @@ export default class System {

this.gameui.draw(this.ctx, this.cv.width, this.cv.height, this.camera.uiz);

} else {
} else { // TODO : From this code to the requestAnimationFrame, all codes must be replaced by "ui.js".
this.ctx.drawImage(this.img, // draw Background image
this.cv.width / 2 - this.img.width * this.camera.uiz / 2 / 2.4,
this.cv.height / 2 - this.img.height * this.camera.uiz / 2 / 2.4,
this.img.width * this.camera.uiz / 2.4,
this.img.height * this.camera.uiz / 2.4);
}

if (this.gameSetting.isConnecting) { // connecting text
this.textinputanime = 1;
this.connectinga = Math.min(this.connectinga + 0.01 * tick,1);
}

if (this.gameSetting.isNaming || this.gameSetting.isConnecting) { // draw Black Alpha Panel
this.panela = Math.min(this.panela + 0.05, 0.4);
Expand Down

0 comments on commit 92450ea

Please sign in to comment.