Unity3D

二月 1st, 2012 by Cup | No Comments | Filed in Program, Unity3D

关注U3D挺长时间了 最近发现U3D有种愈演愈烈的架势
分享一个去年瞎做的 demo

tank

Tags:

NingXia

一月 31st, 2012 by Cup | No Comments | Filed in Photo, cup'life

背井离乡打拼了这些年 回头看看家乡还是那么舒服那么美

发展快到让我觉得自己在退步了


Tags:

Alive

九月 29th, 2011 by Cup | 1 Comment | Filed in Photo, cup'life

有些日子没出来活动了 今天出来才觉得

身体被自己糟蹋的得了大病  真不知还得病多久 医生居然说最少还得半年

每天吃那么多药 没病也能吃出些病来

想想片子上已经空了的那半边肺  后怕..

本想着 在休息的这些日子 做很多事 可是 吃了药  人不得不睡觉

吃了睡  睡了吃

梦总是很多 可想想正事 一切还是迷茫

房价好像不怎么涨了 可是好像还是买不起啊

有同事最近要结婚了 恭喜 可惜我也去不了

没病的时候 经常幻想有 几个月 辞职出去 川藏  来一回间隔年

呵呵 ..现在终于有时间了 却哪也去不了  连门口的公园一口气都 逛不下来..   想想真可笑

苦笑..

Tags:

Particles Html5 Javascript

五月 18th, 2011 by Cup | 评论关闭 | Filed in Program

建议用 Chrome  ,  Firefox 浏览   Chrome 的运行效率会高一些

<code>


var MAX_NUM = 3000;

var WIDTH = window.innerWidth;

var HEIGHT = window.innerHeight;

function Particle()

{

this.initialize.apply(this, arguments);

}

Particle.prototype =

{

initialize: function(x, y)

{

this.x = x;

this.y = y;

},

x : 0,

y : 0,

vx : 0,

vy : 0,

next : null // Link

};

// 画布

var canvas = document.createElement("canvas");

canvas.width = WIDTH;

canvas.height = HEIGHT;

document.body.appendChild(canvas);

var context = canvas.getContext("2d");

var first;

var old;

// 创建粒子

for(var i=0; i<MAX_NUM; i++) {

var p = new Particle(Math.random() * WIDTH , Math.random() * HEIGHT);

if(first == null) {

first = old = p;

} else {

old.next = p;

old = p;

}

}

document.addEventListener('mousemove', mouseMoveHandler, false);

var mouseX = 0;

var mouseY = 0;

function mouseMoveHandler(e)

{

mouseX = e.clientX ;

mouseY = e.clientY ;

}

setInterval(loop, 1000 / 60);//循环

function loop() {

// 填充背景

context.fillStyle = "rgb(0, 0, 0)";

context.fillRect(0, 0, WIDTH, HEIGHT);

var n = first;

//

do {

var diffX = mouseX - n.x;

var diffY = mouseY - n.y;

var acc = 30 / (diffX * diffX + diffY * diffY);

var accX = acc * diffX;

var accY = acc * diffY;

n.vx += accX;

n.vy += accY;

n.x += n.vx;

n.y += n.vy;

n.vx *= 0.96;

n.vy *= 0.96;

if (n.x > WIDTH)

n.x = 0;

else if (n.x < 0)

n.x = WIDTH;

if (n.y > HEIGHT)

n.y = 0;

else if (n.y < 0)

n.y = HEIGHT;

// 填充点

context.fillStyle = "rgb(195, 35, 100)";

context.fillRect(n.x, n.y, Math.floor(Math.random()*4+1), Math.floor(Math.random()+1));

}

while (n = n.next);

}

</code>

Tags: ,

Car Game

五月 16th, 2011 by Cup | No Comments | Filed in Program

<code>


//物体透视位置
private function move(tree:GameTree):void {
var angle:Number = (gameRotation - 90) / 180 * Math.PI;
var cosY:Number = Math.cos(angle);
var sinY:Number = Math.sin(angle);
var vx:int = tree.xpos + xPos;
var vy:int = tree.zpos - yPos;
var tx:Number = vy * sinY + vx * cosY;
var ty:Number = vy * cosY - vx * sinY;
tree.dis = ty;
if (ty < 0) {
tree.visible = false;
} else {
tree.visible = true;
var StripCount:int = gridTotalHeight;
var mCamHeight:int = heightScale;
var d:int = -ty * (StripCount * 2 * mCamHeight) / (StripCount + 2 * mCamHeight * ty);
tree.x = tx * mCamHeight / StripCount * ((StripCount + d) * 2.2);
tree.y = d;
tree.scaleX = tree.scaleY = ((StripCount + d) * (mCamHeight) / 1) * .01;
tree.scaleX = tree.scaleY = tree.scaleX * .5;
}
}

//排序
private function sortZ():void {
trees.sortOn("dis", Array.DESCENDING | Array.NUMERIC);
for (var i:uint = 0; i < trees.length; i++) {
var tree:GameTree = trees[i];
objSpr.setChildIndex(tree, i);
}
}

//创建场景
private function create3DScene():void {
objGrids = new Object();
mapSpr = new Sprite();
objSpr = new Sprite();
mapSpr.y = gameHeight/2;
Screen.addChild(mapSpr);
objSpr.y = gameHeight;
objSpr.x = gameWidth / 2;
Screen.addChild(objSpr);
createGrids_();
cosRot = Math.cos(gameRotation * (Math.PI / 180));
sinRot = Math.sin(gameRotation * (Math.PI / 180));
this.addEventListener(Event.ENTER_FRAME, onEnterFrame);
Key.initialize(stage);
createObj();
}

private function gameEnterFrame():void {
if (Key.isDown(37)) ////lift
{
ro += .5;
if (ro > 3) ro = 4;
angleY = ( -ro / 180) * Math.PI;

if (lean < 4) lean+=.5;

} else if (Key.isDown(39)) ////right
{
ro -= .5;
if (ro < -3) ro = -4;
angleY = (ro / 180) * Math.PI;

if (lean > -4) lean-=.5;

} else {
if (ro > 0) {
ro -= .5;
} else if(ro < 0) {
ro += .5;
}
angleY = 0;
}

if (Math.abs(lean) < 0.1)
{
lean = 0;
} else {
lean *= 0.8;
}
Screen.rotation = lean;

if (Key.isDown(38) && speed <= 5) ////加速
{
speed += 0.3;
} else if (Key.isDown(40) && speed >= -2) /////减速
{
speed -= 0.15;
} else {
speed *= 0.94;
if (speed < 0) speed = 0;
}

/////sky
for (var j:int = 1; j <=3; j++)
{
m1Back["s" + j].x += j +ro * j;
if (m1Back["s" + j].x >= 0) m1Back["s" + j].x = -510;
if (m1Back["s" + j].x <= -1024) m1Back["s" + j].x = -514;
}

gameRotation += ro;
cosRot = Math.cos(gameRotation * (Math.PI / 180));
sinRot = Math.sin(gameRotation * (Math.PI / 180));

var friction:Number = .94;///

vy1 -= (friction * Math.cos(gameRotation*(Math.PI/180)))*speed/11;
vx1 += (friction * Math.sin(gameRotation * (Math.PI / 180))) * speed / 11;

if (Tree != null) Tree.zpos ++;

vx1 *= friction;
vy1 *= friction;
xPos += vy1;
yPos += vx1;

//////地图
pp.x = Math.abs(xPos * .1);
pp.y = Math.abs(yPos * .1);

////赛道碰撞检测
if (!map1Test.hitTestPoint(Math.abs(xPos), Math.abs(yPos), true)) {
speed *= 0.8;
if (speed < .01) speed = 0;

//////车震
var zheny:Number = Math.random() * speed * 2 - speed;
Screen.y = zheny * 3;
Screen.x = zheny;
}

for (var i:int = 1; i <= gridNum; i++ ) {
objGrids["m" + i].rotation = gameRotation-90;
objGrids["m" + i].m1.x = xPos;
objGrids["m" + i].m1.y = yPos;
}

objEnterFrame();
}

private function onEnterFrame(evt:Event):void {
gameEnterFrame();
}

private function createGrid_(mc:MovieClip, h:int):Mask {
var grid:Mask = new Mask();
mc.mask = grid;
return grid;
}

//生成格子
private function createGrids_():void {
var gridHeight:int = 0;
for (var i:int = 1; i <= gridNum; i++) {
var map:MapMc = new MapMc();
objGrids["m" + i] = map;
mapSpr.addChild(map);
map.x = gameWidth / 2;
map.y = gameHeight / 2;
map.scaleX = map.scaleY = (gridHeight/gridTotalHeight)*gridTotalHeight * heightScale*.01;
map.m1.x = yPos;
map.m1.y = xPos;
var grid:Mask = createGrid_(map, -gridHeight);
grid.y = gridHeight;
mapSpr.addChild(grid);
var scale1:Number = Math.pow(i/(gridTotalHeight/2.5), 1.5);
var height1:Number = Math.round(1 + (4 - 1) * scale1);
grid.height = height1;
gridHeight += height1;
}

</code>

第一视角游戏

来自很老的一个例子        源文件 z_mapping.fla

University

四月 18th, 2011 by Cup | 6 Comments | Filed in Photo, cup'life

今年春天来得很早  暖暖的

最近结婚的朋友特别多  有点小惆怅

不过想想 玩的很好的一个发小孩子都上小学了 既然这样自己也无所谓了

周末去周边的大学散散步  又回想自己的 大学时怎么过的  呵呵

想想如今有时加班忙的昏天暗地 衣服都抽不出时间来洗

所以羡慕啊 呵呵

不过看豆豆还是挺乐的

Tags:

Nice

三月 2nd, 2011 by Cup | No Comments | Filed in Photo, cup'life

Qingdao

二月 9th, 2011 by Cup | No Comments | Filed in Photo, cup'life













Spring Festival

一月 26th, 2011 by Cup | No Comments | Filed in cup'life

Merry Christmas

十二月 23rd, 2010 by Cup | No Comments | Filed in Program, cup'life