목록창고/JS KING 포니 [중단] (81)
도드넷
if not now then when?, if not me then who?, if not her then whom? MARRY ME AJ! JAVASCRIPT#78 - offset 오프셋에 관하여 gf.offset = function(div){// 1. 해당 div의 데이터를 불러와서 options에 저장한다. 이후 x, y 값을 저장한다. var options = div.data("gf"); var x = options.x; var y = options.y; // 2. 해당 div의 부모 요소와 그 데이터를 불러와서 options에 저장한다. var parent = $(div.parent()); options = parent.data("gf"); // 3. 부모요소의 x, y를 더해주고 그 부모의 부..
Big things have small beginnings... JAVASCRIPT#77 - 탑다운 1부 1. 게임의 시작 $("#startButton").click(function() { gf.startGame(initialize); }); 스타트 버튼이라는 요소를 클릭하면 gf.startGame 함수가 initialize라는 파라미터와 함께 시작된다. 2. gf.startGame 과 initialize 함수 gf.startGame = function(endCallback, progressCallback) { // 1. 이미지 배열과 프리로드 var images = []; var total = gf.imagesToPreload.length; for (var i = 0; i < total; i++) { ..
I can only hope, i can only prey that someday in some point of my life, i finally meet you and we fall in love. JAVASCRIPT#76 - 횡스크롤 101 모든 함수정리 1. 스프라이트 추가하기 1. 스프라이트 프래그먼트 선언. gf.spriteFragment = $(""); 2. 스프라이트 DOM 객체 생성함수. gf.addSprite = function(parent, divId, options) {2-1. 스프라이트의 프로퍼티를 설정. var options = $.extend({ x: 0, y: 0, width: 64, height: 64, flipH: false, flipV: false, rotate: 0, s..
Making game and loving pony is like chasing a thunder! JAVASCRIPT#75 - 자바스크립트 data 메소드 data("gf")의 존재에 대하여 1. 표현을 창에 제한하기 style='position: absolute; overflow: hidden;' 을 추가한다. ㅇ_ㅇ 2. data("gf")에 대하여 data 메소드는 DOM 엘레멘트와 데이터를 연결하는 메소드이다. var sprite = gf.spriteFragment.clone().css({ left: options.x, top: options.y, width: options.width, height: options.height}).attr("id",divId).data("gf",options); ..
You should stop focusing what you can't do, and start doing something you can, its won't be anything big or fancy but something got to be better than nothing, and that's the start. JAVASCRIPT#74 - 중력 연출하기 가속도 붙이면서 어떤 오브젝트의 위치를 Y축 방향으로 계속 끌어당기면 그게 중력인데... function physics(obj, collider) { var delta = 30; obj.fallingSpeed = Math.min(100, Math.max(-100, obj.fallingSpeed + obj.gravity * delta / 100)..
God, please let me marry Applejack :3 JAVASCRIPT#73 - 자바스크립트 충돌 검출 V2 충돌검사 재대로 만들어보자. gf.intersect = function(a1,a2,b1,b2){ var i1 = Math.min(Math.max(a1, b1), a2); var i2 = Math.max(Math.min(a2, b2), a1); return [i1, i2]; } 첫번째 함수는 인터섹트 함수인데 Math.min 메소드와 Math.max 메소드가 주로 쓰였다. 둘은 괄호안의 값들중 최대값 또는 최솟값을 반환하는 메소드이다. intersect 함수가 하는 일은 두 선분의 겹치는 위치 (충돌 겹침 포인트)를 반환한다. 리턴값 형태가 좀 특이한데 이건, 배열행태로 i1 과 i..
This Ain't no place for the hero.. JAVASCRIPT#72 - 자바스크립트 2차원 배열을 통해서 타일셋 만들기 이제 프로그에서 넘어가서 횡스크롤 게임 만드는것 같은데... 일단 타일셋 소환하는 함수 내입맛대로 만들어봄. // tile // function tileMap(url, width, height, tilewidth, tileheight, map) { this.url = url; this.parentId = "mygame"; // Total tilemap size this.width = width; this.height = height; // Starting point of first tile this.x = 0; this.y = 0; // A tile unit widt..
aw so cute :3 look at her glasses and tie on her tail. aww she is killin me with her cutieness animate.animation.numberOfFrame){ finishedAnimations.push(i); } else { animate.animation.currentFrame %= animate.animation.numberOfFrame; gf.setFrame(animate.div, animate.animation); } } } for(var i=0; i < finishedAnimations.length; i++){ gf.animations.splice(finishedAnimations[i], 1); } // execute the..
I will burn down whole world if i have to, only thing that matters in this world is you AJ. JAVASCRIPT#70 - 데스컨디션 + 랜덤위치와 충돌 구현2 1. 좀비의 다량생성과 각자 다른 위치와 속도 애니메이션 재생을 위해서 오브젝트를 아예 새로 만들어버림. function Zombief(divId, dir, x, y) { this.divId = divId; this.url = 'url("Images/zombie.png")'; this.width = 28; this.height = 60; this.direction = dir; this.speed = getRandomInt(3, 12); this.x = x; this.y = y;..
I used to be love drunk now i'm in hang over i need your love for breakfast ♥ Marry me applejack JAVASCRIPT#69 - 메인루프와 물체 움직이기 충돌 구현 1. 메인 루프- 게임 실행후 지속적으로 반복되는 함수 부분- 지속적으로 물체(나뭇조각)을 움직이게한다. - 해당라인의 물살 속도에 맞춰 플레도 함께 움직이게 한다. var gameloop = function() { packets1.position = packets1.position + packets1.speed; packets2.position = packets2.position + packets2.speed; packets3.position = packets3.pos..