`
xnewer
  • 浏览: 1901 次
  • 性别: Icon_minigender_1
  • 来自: 上海
最近访客 更多访客>>
文章分类
社区版块
存档分类
最新评论

andorid 3d opengl

阅读更多
http://code.google.com/p/rokon/
http://code.google.com/p/loon-simple/downloads/list?q=label:java

import os
from google.appengine.ext.webapp import template
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

class ScoreBoard(db.Model):
    user = db.UserProperty(required=True)
    level = db.IntegerProperty(required=True)
    lifes = db.IntegerProperty(required=True)
    date = db.DateTimeProperty(auto_now=True)

class List(webapp.RequestHandler): 
    def get(self):
        list = ScoreBoard.all().order('-level');
        top10 = list.fetch(10);
        template_values={
             "list":top10,
             }
        path = os.path.join(os.path.dirname(__file__), 'list.html')
        self.response.out.write(template.render(path, template_values))

class Add(webapp.RequestHandler): 
    def post(self):
        score = ScoreBoard(user= self.request.get('user'), level=self.request.get('level'),
                       lifes = self.request.get('lifes'))
        db.put(score);
        self.response.out.write("ok");

application = webapp.WSGIApplication([('/list', List),('/add', Add)], debug=True)


def main():
    run_wsgi_app(application)

if __name__ == "__main__":
    main()
分享到:
评论
34 楼 xnewer 2012-07-27  
jjjjj
33 楼 xnewer 2012-07-27  
xxxxx
32 楼 xnewer 2011-01-13  
Addison.Wesley.Cocoa.Programming.for.Mac.OS.X.3rd.Edition.May.2008.chm
31 楼 xnewer 2010-12-24  
public class PlayScene extends BaseScene {
public static final int COLORNUM = 7;
public static final int INTERVAL = 1000;
public static final int TOTAL_TIME = 200;
public static final int BONUS = 5;

public Container container;
public int countdownTimer;
public int bonusTimer;
public int lastScorePoint;
public PlayScene(Container container){
this.container = container;
this.container.playScene = this;
}

@Override
public void onLoad() {
super.onLoad();

container.createBalls();

setText("time", TOTAL_TIME);

countdownTimer = setTimer(INTERVAL, new Timerable() {
@Override
public boolean onTimer() {

if (getText("time") > 0) {
setText("time", getText("time") - 1);
return true;
} else {
GameoverScene gameoverScene = new GameoverScene(
getText("time"), getText("score"),
getText("lives"), getText("stage"),
GameoverScene.TIME_UP);
swtichScene(gameoverScene);
return false;
}
}
});

@Override
public void onTouchEvent(int x, int y) {
if (y < Container4.CellSize)
return;
Pair location = container.getLocation(x, y - Container4.CellSize);
int i = location.x;
int j = location.y;
if (container.balls[i][j] != null) {
return;
}

ArrayList<Ball> sameColorBalls = container.getSameColorAdjs(i, j);
if(sameColorBalls.size()<=0)
return;


onMoveBalls(sameColorBalls, location);

}

private void onMoveBalls(ArrayList<Ball> sameColorBalls, Pair location) {
// TODO Auto-generated method stub

}





}
30 楼 xnewer 2010-12-24  
package lxstudio.imatch;

import java.util.ArrayList;

import lxstudio.lib.Engine;
import lxstudio.lib.Pair;

public class Container4 extends Container {

public Container4() {
this.rowNumber = Engine.VitualSize.y / CellSize - 1;
this.colNumber = Engine.VitualSize.x / CellSize;
balls = new Ball[rowNumber][colNumber];
}

public Pair getBallCenterPos(Pair location) {
int x = Container.CellSize * location.x + Container.CellSize / 2;
int y = Container.CellSize * location.y + Container.CellSize / 2
+ Container.CellSize;
return new Pair(x, y);
}


public ArrayList<Ball> getAdjBall(int i, int j) {
ArrayList<Ball> adjs = new ArrayList<Ball>();
int k = i - 1;
for (; k >= 0 && balls[k][j] == null; k--) {
}
if (k >= 0) {
adjs.add(balls[k][j]);
}

k = i + 1;
for (; k <= rowNumber - 1 && balls[k][j] == null; k++) {
}
if (k <= colNumber - 1) {
adjs.add(balls[k][j]);
}

k = j - 1;
for (; k >= 0 && balls[i][k] == null; k--) {
}
if (k >= 0) {
adjs.add(balls[i][k]);
}

k = j + 1;
for (; k <= colNumber - 1 && balls[i][k] == null; k++) {
}
if (k <= colNumber - 1) {
adjs.add(balls[i][k]);
}

return adjs;
}

public void moveBalls(Pair location, int direction, boolean twoStep) {
int velocity = 100;
switch (direction) {
case 0:// up
for (int i = location.y; i < rowNumber; i++) {
Ball ball = balls[i][location.x];
if (ball != null) {
Pair newLocation = new Pair();
newLocation.x = ball.location.x;
newLocation.y = twoStep ? ball.location.y - 2
: ball.location.y - 1;
ball.moveTo(getBallCenterPos(newLocation), new Pair(0,
-velocity));
}
balls[i - (twoStep ? 2 : 1)][location.x] = balls[i][location.x];
}
balls[rowNumber - 1][location.x] = null;
break;
case 1:// right
for (int i = location.y; i < rowNumber; i++) {
Ball ball = balls[i][location.x];
if (ball != null) {
Pair newLocation = new Pair();
newLocation.x = ball.location.x;
newLocation.y = twoStep ? ball.location.y - 2
: ball.location.y - 1;
ball.moveTo(getBallCenterPos(newLocation), new Pair(0,
-velocity));
}
balls[i - (twoStep ? 2 : 1)][location.x] = balls[i][location.x];
}
balls[rowNumber - 1][location.x] = null;
break;
case 2:// down
break;
case 3:// left
break;
}
}

}
29 楼 xnewer 2010-12-24  
package lxstudio.imatch;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Random;
import java.util.Map.Entry;

import lxstudio.lib.Pair;

public abstract class Container {
public PlayScene playScene;
public int rowNumber;
public int colNumber;
public static final int CellSize = 48;
public Ball[][] balls;

public abstract Pair getBallCenterPos(Pair location);
public abstract ArrayList<Ball> getAdjBall(int i, int j);
public abstract void moveBalls(Pair beginLocation, int direction, boolean twoStep);

public void createBall(Pair location, int color) {
Ball ball = new Ball(this, location, color);
balls[location.y][location.x] = ball;
playScene.add(1, ball);
}

public void createBalls() {
Random rand = new Random();
for (int i = 0; i < colNumber; i++) {
for (int j = 0; j < rowNumber; j++) {
if (rand.nextInt(3) == 1) {
createBall(new Pair(i, j), rand.nextInt(PlayScene.COLORNUM));
}
}
}
}

public ArrayList<Ball> getSameColorAdjs(int i, int j){
ArrayList<Ball> adjBalls = getAdjBall(i, j);
return getSameColor(adjBalls);
}

private ArrayList<Ball> getSameColor(ArrayList<Ball> adjBalls) {
ArrayList<Ball> sameColorBalls = new ArrayList<Ball>();
HashMap<Integer, ArrayList<Ball>> hashMap = new HashMap<Integer, ArrayList<Ball>>();
for (int k = 0; k < adjBalls.size(); k++) {
int color = adjBalls.get(k).color;
if (!hashMap.containsKey(color)) {
hashMap.put(color, new ArrayList<Ball>());
}
hashMap.get(color).add(adjBalls.get(k));
}
for (Entry<Integer, ArrayList<Ball>> pair : hashMap.entrySet()) {
if (pair.getValue().size() > 1) {
sameColorBalls.addAll(pair.getValue());
}
}
return sameColorBalls;
}


public Pair getLocation(int x, int y){
return new Pair(x / CellSize, y / CellSize);
}


}
28 楼 xnewer 2010-12-18  
public class Cell extends Sprite {
public static final int Size = 48;
private int _directionNumber = 4;
private HashMap<Integer, Cell> _adjCells = new HashMap<Integer, Cell>();
private Pair _location = new Pair();

public Cell(Pair location) {
_location = location;
}

public boolean hasBall() {
return getNext() != null;
}

private int getOppDirection(int direction) {
return (direction + _directionNumber / 2) % _directionNumber;
}

public void move(int direction, int step) {
// this.moveTo(dstCenter, velocity);
int oppDirection = getOppDirection(direction);
if (_adjCells.containsKey(oppDirection)) {
_adjCells.get(oppDirection).move(direction, step);
}
}

public Pair getLocation() {
return _location;
}

public void setLocation(Pair location) {
_location = location;
}

}
27 楼 xnewer 2010-12-17  





Network Working Group                                      G. Sidebottom
Request for Comments: 3332                         Signatus Technologies
Category: Standards Track                                   K. Morneault
                                                                   Cisco
                                                        J. Pastor-Balbas
                                                                Ericsson
                                                                 Editors
                                                          September 2002


       Signaling System 7 (SS7) Message Transfer Part 3 (MTP3) -
                      User Adaptation Layer (M3UA)

Status of this Memo

   This document specifies an Internet standards track protocol for the
   Internet community, and requests discussion and suggestions for
   improvements.  Please refer to the current edition of the "Internet
   Official Protocol Standards" (STD 1) for the standardization state
   and status of this protocol.  Distribution of this memo is unlimited.

Copyright Notice

   Copyright (C) The Internet Society (2002).  All Rights Reserved.

Abstract

   This memo defines a protocol for supporting the transport of any SS7
   MTP3-User signalling (e.g., ISUP and SCCP messages) over IP using the
   services of the Stream Control Transmission Protocol.  Also,
   provision is made for protocol elements that enable a seamless
   operation of the MTP3-User peers in the SS7 and IP domains. This
   protocol would be used between a Signalling Gateway (SG) and a Media
   Gateway Controller (MGC) or  IP-resident Database, or between two
   IP-based applications.  It is assumed that the SG receives SS7
   signalling over a standard SS7 interface using the SS7 Message
   Transfer Part (MTP) to provide transport.

Table of Contents

   1.  Introduction..................................................3
   1.1 Scope.........................................................3
   1.2 Terminology...................................................4
   1.3 M3UA Overview.................................................6
   1.4 Functional Areas.............................................10
   1.5 Sample Configurations........................................18
   1.6 Definition of M3UA Boundaries................................21
   2.  Conventions..................................................25



Sidebottom, et. al.         Standards Track                     [Page 1]

RFC 3332             SS7 MTP3-User Adaptation Layer       September 2002


   3.  M3UA Protocol Elements.......................................25
   3.1 Common Message Header........................................26
   3.2 Variable Length Parameter....................................29
   3.3 Transfer Messages............................................31
   3.4 SS7 Signalling Network Management (SSNM) Messages............35
   3.5 ASP State Maintenance (ASPSM) Messages.......................45
   3.6 Routing Key Management (RKM) Messages........................48
   3.7 ASP Traffic Maintenance (ASPTM) Messages.....................59
   3.8 Management (MGMT) Messages...................................63
   4.  Procedures...................................................69
   4.1 Procedures to Support the M3UA-User .........................69
   4.2 Procedures to Support the Management of SCTP Associations ...70
   4.3 AS and ASP State Maintenance.................................72
   4.4 Routing Key Management Procedures............................87
   4.5 Procedures to Support the Availability or Congestion Status
       of SS7 Destination...........................................89
   4.6 MTP3 Restart.................................................92
   5.  Examples of M3UA Procedures..................................93
   5.1 Establishment of Association and Traffic
26 楼 xnewer 2010-12-17  





Network Working Group                                      G. Sidebottom
Request for Comments: 3332                         Signatus Technologies
Category: Standards Track                                   K. Morneault
                                                                   Cisco
                                                        J. Pastor-Balbas
                                                                Ericsson
                                                                 Editors
                                                          September 2002


       Signaling System 7 (SS7) Message Transfer Part 3 (MTP3) -
                      User Adaptation Layer (M3UA)

Status of this Memo

   This document specifies an Internet standards track protocol for the
   Internet community, and requests discussion and suggestions for
   improvements.  Please refer to the current edition of the "Internet
   Official Protocol Standards" (STD 1) for the standardization state
   and status of this protocol.  Distribution of this memo is unlimited.

Copyright Notice

   Copyright (C) The Internet Society (2002).  All Rights Reserved.

Abstract

   This memo defines a protocol for supporting the transport of any SS7
   MTP3-User signalling (e.g., ISUP and SCCP messages) over IP using the
   services of the Stream Control Transmission Protocol.  Also,
   provision is made for protocol elements that enable a seamless
   operation of the MTP3-User peers in the SS7 and IP domains. This
   protocol would be used between a Signalling Gateway (SG) and a Media
   Gateway Controller (MGC) or  IP-resident Database, or between two
   IP-based applications.  It is assumed that the SG receives SS7
   signalling over a standard SS7 interface using the SS7 Message
   Transfer Part (MTP) to provide transport.

Table of Contents

   1.  Introduction..................................................3
   1.1 Scope.........................................................3
   1.2 Terminology...................................................4
   1.3 M3UA Overview.................................................6
   1.4 Functional Areas.............................................10
   1.5 Sample Configurations........................................18
   1.6 Definition of M3UA Boundaries................................21
   2.  Conventions..................................................25



Sidebottom, et. al.         Standards Track                     [Page 1]

RFC 3332             SS7 MTP3-User Adaptation Layer       September 2002


   3.  M3UA Protocol Elements.......................................25
   3.1 Common Message Header........................................26
   3.2 Variable Length Parameter....................................29
   3.3 Transfer Messages............................................31
   3.4 SS7 Signalling Network Management (SSNM) Messages............35
   3.5 ASP State Maintenance (ASPSM) Messages.......................45
   3.6 Routing Key Management (RKM) Messages........................48
   3.7 ASP Traffic Maintenance (ASPTM) Messages.....................59
   3.8 Management (MGMT) Messages...................................63
25 楼 xnewer 2010-12-17  





Network Working Group                                      G. Sidebottom
Request for Comments: 3332                         Signatus Technologies
Category: Standards Track                                   K. Morneault
                                                                   Cisco
                                                        J. Pastor-Balbas
                                                                Ericsson
                                                                 Editors
                                                          September 2002


       Signaling System 7 (SS7) Message Transfer Part 3 (MTP3) -
                      User Adaptation Layer (M3UA)

Status of this Memo

   This document specifies an Internet standards track protocol for the
   Internet community, and requests discussion and suggestions for
   improvements.  Please refer to the current edition of the "Internet
   Official Protocol Standards" (STD 1) for the standardization state
   and status of this protocol.  Distribution of this memo is unlimited.

Copyright Notice

   Copyright (C) The Internet Society (2002).  All Rights Reserved.

Abstract

   This memo defines a protocol for supporting the transport of any SS7
   MTP3-User signalling (e.g., ISUP and SCCP messages) over IP using the
   services of the Stream Control Transmission Protocol.  Also,
   provision is made for protocol elements that enable a seamless
   operation of the MTP3-User peers in the SS7 and IP domains. This
   protocol would be used between a Signalling Gateway (SG) and a Media
   Gateway Controller (MGC) or  IP-resident Database, or between two
   IP-based applications.  It is assumed that the SG receives SS7
   signalling over a standard SS7 interface using the SS7 Message
   Transfer Part (MTP) to provide transport.
24 楼 xnewer 2010-12-17  





Network Working Group                                      G. Sidebottom
Request for Comments: 3332                         Signatus Technologies
Category: Standards Track                                   K. Morneault
                                                                   Cisco
                                                        J. Pastor-Balbas
                                                                Ericsson
                                                                 Editors
                                                          September 2002


       Signaling System 7 (SS7) Message Transfer Part 3 (MTP3) -
                      User Adaptation Layer (M3UA)

Status of this Memo

   This document specifies an Internet standards track protocol for the
   Internet community, and requests discussion and suggestions for
   improvements.  Please refer to the current edition of the "Internet
   Official Protocol Standards" (STD 1) for the standardization state
   and status of this protocol.  Distribution of this memo is unlimited.

Copyright Notice

   Copyright (C) The Internet Society (2002).  All Rights Reserved.

Abstract

   This memo defines a protocol for supporting the transport of any SS7
   MTP3-User signalling (e.g., ISUP and SCCP messages) over IP using the
   services of the Stream Control Transmission Protocol.  Also,
   provision is made for protocol elements that enable a seamless
   operation of the MTP3-User peers in the SS7 and IP domains. This
   protocol would be used between a Signalling Gateway (SG) and a Media
   Gateway Controller (MGC) or  IP-resident Database, or between two
23 楼 xnewer 2010-12-17  
   Copyright (C) The Internet Society (2002).  All Rights Reserved.

   This document and translations of it may be copied and furnished to
   others, and derivative works that comment on or otherwise explain it
   or assist in its implementation may be prepared, copied, published
   and distributed, in whole or in part, without restriction of any
   kind, provided that the above copyright notice and this paragraph are
   included on all such copies and derivative works.  However, this
   document itself may not be modified in any way, such as by removing
   the copyright notice or references to the Internet Society or other
   Internet organizations, except as needed for the purpose of
   developing Internet standards in which case the procedures for
   copyrights defined in the Internet Standards process must be
   followed, or as required to translate it into languages other
   than  English.
22 楼 xnewer 2010-12-15  
protected Scene _scene;
protected Rect _rect = new Rect();
protected String _textureName = "";
private ArrayList<String> _images = new ArrayList<String>();
private ArrayList<ArrayList<String>> _actions = new ArrayList<ArrayList<String>>();

protected int _angle;
protected boolean _repeatTexture;
protected boolean _visiable = true;

private TouchHandle _touchHandle;

private ArrayList<Effect> _effects = new ArrayList<Effect>();

private Sprite _next;

public Sprite() {
}

public void addImage(String textureName) {
_images.add(textureName);
}

public void addAction(String... textureNames) {
_actions.add(new ArrayList<String>(Arrays.asList(textureNames)));

}

public void drawFrame(GL10 gl) {
for (Effect effect : _effects) {
effect.renderFrame(gl);
}
if (_visiable) {
if (!_textureName.equals("")) {
int xCount = 1;
int yCount = 1;
if (_repeatTexture) {
xCount = _rect.width() / _getTextureSize().width;
yCount = _rect.height() / _getTextureSize().height;
}
int textureID = Engine.getInstance().getResource()
.getTextureID(_textureName);
GLWrapper.draw(gl, textureID, _rect, _angle, xCount, yCount);
}
}

if (_next != null) {
_next.drawFrame(gl);
}

}

public void moveTo(Point dst, int seconds){

}

public void move(int velX, int velY){

}



public void killMe() {
if (_scene != null) {
_scene.removeSprite(this);
}
}

public void onTouchEvent(int x, int y) {
if (_touchHandle != null) {
_touchHandle.onTouched(x, y);
}
}

public void setRect(int left, int top, int right, int bottom) {
_rect.set(left, top, right, bottom);
}

public void setRect(Rect rect) {
_rect = rect;
}

public void setRectEx(int centralX, int centralY, int width, int height) {
_rect.set(centralX - width / 2, centralY - height / 2, centralX + width
/ 2, centralY + height / 2);
}

public void setRepeatTexture(boolean repeatTexture) {
_repeatTexture = repeatTexture;
}

public void setTextureName(String textureName) {
_textureName = textureName;
}

public void setTouchHandle(TouchHandle touchHandle) {
_touchHandle = touchHandle;
}

public void stopEffect(Effect effect) {
_effects.remove(effect);
}

public void update() {
if (_moveHandle.isMoving()) {
_moveHandle.update();
}
}
21 楼 xnewer 2010-12-09  
标签类型的应用例子:
TypeExample ::= SEQUENCE {
ss-Code              SS-Code,                          --普通标签
callBarringFeatureList   [APPLICATION 2]Ext-CallBarFtrList,  --应用类标签
extensionContainer    [3]ExtensionContainer,               --上下文类标签
    privateVar             [PRIVATE 4]INTEGER }             --私有类标签




2.4 一个综合的例子
1)类型:
PersonnelRecord ::= [APPLICATION 0] IMPLICIT SET
{ Name,
title [0] VisibleString,
number EmployeeNumber,
dateOfHire [1] Date,
nameOfSpouse [2] Name,
children [3] IMPLICIT
SEQUENCE OF ChildInformation
DEFAULT {}}
ChildInformation ::= SET
{ Name,
dateOfBirth [0] Date}

Name ::= [APPLICATION 1] IMPLICIT SEQUENCE
{givenName VisibleString,
initial VisibleString,
familyName VisibleString}
EmployeeNumber ::= [APPLICATION 2] IMPLICIT INTEGER
Date ::= [APPLICATION 3] IMPLICIT VisibleString
-- YYYYMMDD
2)值:
{ {givenName "John",initial "P",familyName "Smith"},
title "Director",
number 51,
dateOfHire "19710917",
nameOfSpouse {givenName "Mary",initial "T",
familyName "Smith"},
children
{{{givenName "Ralph",initial "T",familyName "Smith"},
dateOfBirth "19571111"},
{{givenName "Susan",initial "B",familyName "Jones"},
dateOfBirth "19590717"}}}
3)编码:
Personnel
Record Length Contents
60 8185
Name Length Contents
61 10
Visible- Length Contents
String
1A 04 "John"
Visible- Length Contents
String
1A 01 "P"
Visible- Length Contents
String
1A 05 "Smith"
Title Length Contents
A0 0A
Visible- Length Contents
String
1A 08 "Director'
Employee
Number Length Contents
42 01 33
Date of
Hire Length Contents
A1 0A
Date Length Contents
43 08 "19710917"
Name of
Spouse Length Contents
A2 12
Name Length Contents
61 10
Visible- Length Contents
String
1A 04 "Mary"
Visible- Length Contents
String
1A 01 "T"
Visible- Length Contents
String
1A 05 "Smith"
[3] Length Contents
A3 42
Set Length Contents
31 1F
Name Length Contents
61 11
Visible- Length Contents
String
1A 05 "Ralph"
Visible- Length Contents
String
1A 01 "T"
Visible- Length Contents
String
1A 05 "Smith"
Date of
Birth Length Contents
A0 0A
Date Length Contents
43 08 "19571111"
Set Length Contents
31 1F
Name Length Contents
61 11
Visible- Length Contents
String
16 05 "Susan"
Visible- Length Contents
String
16 01 "B"
Visible- Length Contents
String
1 05 "Jones"
Date of
Birth Length Contents
A0 0A
Date Length Contents
43 08 "19590717"
20 楼 xnewer 2010-12-09  
ASN.1数据值的编码由按下列顺序排列的四部分组成:标识符八比特组、长度八比特组、内容八比特组以及内容结束八比特组,如图1所示。其中标识符八比特组、长度八比特组是必选部分,内容八比特组以及内容结束八比特组是可选部分。

2.1.1 标识符八比特组(Identifier Octets)
标识符八比特组对数据值类型的ASN.1标记进行编码。ASN.1标记由标记类和序号组成。标记类占据高三位比特位。第8、7比特的内容如图2所示:00 普通,01 应用,10 上下文,11 私有。 第6比特置“1”表示编码方式为构造编码方式,置“0”表示编码方式为元编码方式,其余第5至第1比特表示序号Tag(二进制整数,第5比特为最高比特),如图3所示。若序号大于或等于31,则此5比特置“1”,表示后随一个或多个后继八比特组,后继八比特组除最后一个八比特组之外的每个八比特组的第8比特置“1”,最后一个八比特组的第8比特置“0”,以第一个后继八比特组的第7比特为最高比特,最后一个八比特组的第1比特为最后一个比特,表示标记序号的无符号二进制整数的编码,如图4所示。

2.1.2 长度八比特组(Length Octets)
用长度八比特组表示内容八比特组中的八比特组数。长度八比特组分为确定形和非确定形两种。其划分依据是:若编码为元编码则用确定形;若编码是构造的且都是立即可用的,则可用确定形或非确定形,由发送端选择;若编码是构造的且不都是立即可用的,则用非确定形。
对于确定型,长度八比特组又分为长形式和短形式两种。只有当内容八比特组的组数小于或等于127时,才使用短形式。在短形式中,长度八比特组由单个比特组组成,其中第8比特为“0”,第七比特至第1比特是内容八比特组中的八比特组组数的编码。在长形式中,长度八比特组由一个初始八比特组和一个或几个后继八比特组组成。初始八比特组的第8比特置“1”,第七至1比特为长度八比特组中后继八比特组的组数的编码;后继八比特组的编码等于内容八比特组中的八比特组数的无符号二进制整数编码。确定形的编码如图5所示。
对于非确定型,长度八比特组由单个八比特组80h组成,表示由内容结束八比特组结束内容八比特组。非确定形编码如图6所示。

2.1.3 内容八比特组(Content Octets)
由零、一个或多个八比特组组成的数据值编码。内容八比特组的编码依赖于数据值的类型。
2.1.4 内容结束八比特(End of Contents Octets)
在非确定型编码时出现,由两个零八比特组组成,如图6所示。

2.2 基本类型
2.2.1 BOOLEAN 值(普通类,Tag=1):
编码方式: 元码
长度: 单个Octet
内容: 0~255的无符号整数。
例如:
BOOLEAN 值 TAG LEN CONTENT
TRUE 01 01 FF(非0值)
FALSE 01 01 00

2.2.2 INTEGER 值(普通类,Tag =2):
编码方式: 元码
长度: 一个或多个Octet(s)
内容: 整数值的补码。
规则: 若长度多于一个Octet,则内容的前9个bit(s)不全为“1”,不全为“0”。即将负数去掉多余的前导“1”;正数去掉多余的前导“0”。

2.2.3 ENUMERATED值(普通类,Tag =10)
编码方式: 元码
与之相关的INTEGER值的编码。

2.2.4 BITSTRING值(普通类,Tag =3)
编码方式: 元/构造码
长度: 一个或多个Octet(s)

内容: …

前导Octet取值0~7,指示最后一个后继Octet中,未用bit的个数;后继Octet(s)为BITSTRING值。
说明:Encoder可以决定是否去掉尾部的值为0的bit;如果bitstring的所有bit都为0,则Encoder可以决定编码0个1个或者多个0值的bit。

2.2.5 OCTETSTRING值(普通类,Tag =4)
编码方式: 元/构造码
长度: 零个、一个或多个Octet(s)

2.2.6 NULL值(普通类,Tag =5)
编码方式: 元码
例如:


2.2.7 SEQUENCE / SEQUENCE OF值(普通类,Tag =16)
编码方式: 构造码
长度: 零个、一个或多个Octet(s)
内容: 值的完整编码。
规则: 数据值的顺序按类型定义中出现的顺序。

2.2.8 SET / SET OF值(普通类,Tag =17)
编码方式: 构造码
长度: 零个、一个或多个Octet(s)
内容: 值的完整编码。
规则: 顺序不重要。

2.2.9 CHOICE 值
说明:与被选择了的类型的值的编码相同。

2.2.10 TAGGED值
说明:1)若类型定义中未使用“IMPLICIT(隐式)”,则编码为构造编码,且内容Octets就是完整的基编码。
2)若类型定义中使用了“IMPLICIT(隐式)”,则基编码为构造,编码就为构造;基编码为元码,编码就为元码。内容Octets与基码内容Octets相同。

2.2.11 ANY/OPEN值
任意或者开放类型的编码,就是所包含类型的ASN.1完整编码。

2.2.12 OBJECT IDENTIFIER值(普通类,Tag =6)
编码方式: 元码
内容:按规则拼接在一起的子标识符。
规则:1)编码应尽可能短,故去掉每个客体成分的前导‘0’。
  2)前两个客体成分X、Y做如下处理
X*40+Y
将得到的值作为第一个子标识符。
  3)编码方法同标签(TAGGED)序号编码方法。

2.2.13 CHARACTER STRING值(普通类,Tag =18-22,25-27)
编码方式:元/构造编码
说明:可被看作:[UNIVERSAL x]IMPLICIT OCTET STRING







19 楼 xnewer 2010-10-14  
private int _level;
private int _lives;
private Layer _playLayer = new Layer("playarea.png", 431, 429);
private Layer _bgLayer = new Layer("background.png", 360, 240);
private int _emitterCount = 0;
private int _dripCount = 0;
private int _brokenCount = 0;

@Override
public void init() {
createDrips(new int[]{4, 8, 8, 4});
addLayer(_bgLayer);
addLayer(_playLayer);
}

@Override
public void mainLogic() {


}

private void createDrips(int[] counts) {
ArrayList<Integer> possiblePostions = new ArrayList<Integer>();
for (int i = 0; i < 36; i++) {
possiblePostions.add(i);
}
Random rand = new Random();
for (int i = 0; i < counts.length; i++) {
for (int j = 0; j < counts[i] + rand.nextInt(3); j++) {
int tmpIndex = rand.nextInt(possiblePostions.size());
int index = possiblePostions.get(tmpIndex);
Drip drip = new Drip(index, i + 1);
_playLayer.add(drip);
possiblePostions.remove(tmpIndex);
}
}
}

public int getDripCount() {
return _dripCount;
}

public void setDripCount(int dripCount) {
_dripCount = dripCount;
}

public int getEmitterCount() {
return _emitterCount;
}

public void setEmitterCount(int emitterCount) {
_emitterCount = emitterCount;
}

public void resetBrokenCount() {
_brokenCount = 0;
}

public void incBrokenCount(){
_brokenCount++;
}
18 楼 xnewer 2010-08-27  
public class AI {
private ChessGroup _self;
private ChessGroup _opponent;

public void decide(){
Chess chess = _getSelfChessInTrap();
if(chess!=null){
chess.move(_opponent.camp);
return;
}

chess = _getOpponentChessInTrap();
if(chess!=null){
if(canEat(chess));
eatit(chess);
}

对方最大的被吃棋子 = 可以吃棋子().getMaxLevel();
自己最大的被吃棋子 = 被吃棋子().getMaxLevel();
if(对方最大的被吃棋子>自己最大的被吃棋子){
eatit();
}

进攻棋子 = 计算进攻的棋子();
进攻棋子.next
进攻棋子.moveToward(大本营);
}

private Chess _getSelfChessInTrap(){
for(Chess chess: _self.listChess){
if(_self.traps.contains(chess.location)){
return chess;
}
}
return null;
}

private Chess _getOpponentChessInTrap(){
for(Chess chess: _opponent.listChess){
if(_self.traps.contains(chess.location)){
return chess;
}
}
return null;

}

public void decide1(){

}

}
17 楼 xnewer 2010-08-27  
public class Chess {

    public int level;
    public Point location;
    private ChessGroup _selfGroup;
    private ChessGroup _opponetGroup;

    public Chess(ChessGroup selfGroup, ChessGroup opponentGroup) {
        _selfGroup = selfGroup;
        _opponetGroup = opponentGroup;
    }
   
    public ArrayList<Point> getBoardLocation(){
        ArrayList<Point> locations = new ArrayList<Point>();
        if(location.y!=0){
        locations.add(new Point(location.x, location.y - 1));       
        }
        if(location.y!=8){
        locations.add(new Point(location.x, location.y + 1));       
        }
        if(location.x!=0){
        locations.add(new Point(location.x - 1, location.y));       
        }
        if(location.x!=6){
        locations.add(new Point(location.x + 1, location.y));       
        }
        return locations;
    }
   
    public ArrayList<Point> getNextLocations() {
        ArrayList<Point> possibleLocations = getBoardLocation();
        ArrayList<Point> nextLocations = new ArrayList<Point>();
        for (Point possiblelocation : possibleLocations) {
            if (_selfGroup.color == ChessGroup.BLUE) {
                if (possiblelocation.x == 3 && possiblelocation.y == {
                    continue;
                }
            } else {
                if (possiblelocation.x == 3 && possiblelocation.y == 0) {
                    continue;
                }
            }

            if(_selfGroup.contain(possiblelocation)){
            continue;
            }

            if (_opponetGroup.contain(possiblelocation)) {
                if (_opponetGroup.get(possiblelocation).level > level
                && !_selfGroup.traps.contains(possiblelocation)) {
                    continue;
                }
            }
            nextLocations.add(possiblelocation);
        }
        return nextLocations;
    }
   
    public void move(Point location){
    this.location.setLocation(location);
    }
   
    public void take(Chess chess){
    _opponetGroup.removeChess(chess);
    this.location.setLocation(chess.location);
    }

}
16 楼 xnewer 2010-08-26  
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedList;

/**
*
* @author user
*/
public class ChessGroup {
    public int color;
    public final static int RED = 1;
    public final static int BLUE = 1;
   
    public ArrayList<Point> traps = new ArrayList<Point>();
    public HashMap<Point, ChessMan> mapChessMan = new HashMap<Point, ChessMan>();
    public LinkedList<ChessMan> listChessMan = new LinkedList<ChessMan>();


    public ChessGroup(int color){
        this.color = color;
        if(color == RED){
            traps.add(new Point(2, 0));
            traps.add(new Point(4, 0));
        }else{
            traps.add(new Point(2,);
            traps.add(new Point(4,);
        }
    }

    public void addChess(ChessMan chess) {
        mapChessMan.put(chess.location, chess);
        listChessMan.add(chess);
        Collections.sort(listChessMan, new Comparator<ChessMan>() {

            public int compare(ChessMan arg0, ChessMan arg1) {
                return (arg0.level == arg1.level) ? 0
                        : arg0.level > arg1.level ? 1 : -1;
            }
        });
    }

    public void removeChess(ChessMan chess) {
        mapChessMan.remove(chess.location);
        listChessMan.remove(chess);
    }

    public int size() {
        return listChessMan.size();
    }

    public ChessMan get(int index) {
        return listChessMan.get(index);
    }

    public boolean containChessMan(Point location){
        return mapChessMan.containsKey(location);
    }

    public ChessMan getChessMan(Point location) {
        return mapChessMan.containsKey(location) ? mapChessMan.get(location) : null;
    }
}
15 楼 xnewer 2010-08-26  
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package test;

import java.awt.Point;
import java.util.ArrayList;

/**
*
* @author user
*/
public class ChessMan {

    public int level;
    public Point location;
    private ChessGroup _selfGroup;
    private ChessGroup _opponetGroup;

    public ChessMan(ChessGroup selfGroup, ChessGroup opponentGroup) {
        _selfGroup = selfGroup;
        _opponetGroup = opponentGroup;
    }

    public ArrayList<Point> getNextLocations() {
        ArrayList<Point> possibleLocations = new ArrayList<Point>();
        possibleLocations.add(new Point(location.x, location.y - 1));
        possibleLocations.add(new Point(location.x, location.y + 1));
        possibleLocations.add(new Point(location.x - 1, location.y));
        possibleLocations.add(new Point(location.x + 1, location.y));

        ArrayList<Point> nextLocations = new ArrayList<Point>();
        for (Point possiblelocation : possibleLocations) {
            if (possiblelocation.x < 0 || possiblelocation.x > 6 || possiblelocation.y < 0 || possiblelocation.y > {
                continue;
            }
            if (_selfGroup.color == ChessGroup.BLUE) {
                if (possiblelocation.x == 3 && possiblelocation.y == {
                    continue;
                }
            } else {
                if (possiblelocation.x == 3 && possiblelocation.y == 0) {
                    continue;
                }
            }

            if (!_selfGroup.containChessMan(possiblelocation)) {
                if (_opponetGroup.containChessMan(possiblelocation)) {
                    if (_selfGroup.traps.contains(possiblelocation)
                            || level >= _opponetGroup.getChessMan(possiblelocation).level) {
                        nextLocations.add(possiblelocation);
                    }
                }
            }
        }
        return nextLocations;
    }
}

相关推荐

    Android 3D OpenGL ES技术详解

    Android 平台OpenGL ES技术详解,3D开发原理性讲的比较通彻

    Android_3D_OpenGL ES 基础教程

    Android 3D OpenGL ES 基础教程 Android 3D OpenGL ES 基础教程是一份关于 Android 3D 游戏开发的入门教程,涵盖了从基本概念到实践的所有知识点。本教程的主要内容包括 OpenGL 相关的术语、3D 游戏开发的基本概念...

    Android 3D实例-openGL

    Android 3D openGL 实例, 触摸旋转,通过eclipse ADT插件直接导入即可运行,源码参考性比较高

    androidOpenGL实现3d动画

    这是用androidOpenGL 实现的3D 动画 导入工程即可运行。

    android-opengl图片3d旋转

    在Android平台上,OpenGL ES是一种广泛使用的图形库,用于在移动设备上实现高性能的2D和3D图形渲染。本文将深入探讨如何使用OpenGL ES在Android上实现图片的3D旋转。 首先,理解OpenGL ES的基本概念至关重要。...

    Android中opengl es要实现Obj格式的3D导入

    OpenGL ES在Android平台上的应用是实现3D图形渲染的关键技术,而Obj文件格式是一种常见的3D模型数据交换格式。在Android开发中,如果想要将Obj格式的3D模型导入到应用中,就需要对OpenGL ES有深入的理解,并且掌握...

    Android OpenGL绘制STL 3D模型

    在Android平台上,OpenGL是一个强大的图形库,用于渲染2D和3D图像。本文将深入探讨如何使用OpenGL在Android上绘制STL(立体光刻)3D模型,特别关注创建一个3D指南针效果。STL是一种广泛用于3D打印和计算机辅助设计...

    Android-EasyShow3D一个基于OpenGLES的简单易用的3D模型展示框架

    《Android-EasyShow3D:基于OpenGLES的3D模型展示框架详解》 在移动设备上实现3D模型的展示已经成为许多应用不可或缺的功能,尤其是在游戏、设计、教育等领域。Android-EasyShow3D就是这样一款专为Android平台设计...

    Android 3D游戏开发技术宝典:OpenGL ES 2.0 源代码.7z

    如题,Android 3D游戏开发技术宝典:OpenGL ES 2.0书中的全部源代码。该书由浅入深的讲解了OpenGL ES 2.0在3D游戏开发中的各个方面,还给出了BN赛艇、火力篮球、夜鹰行动三个经典游戏的全部源代码。

    OpenGL.rar_android_android 3D_android opengl 3D_opengl_opengl 旋转

    这个"OpenGL.rar"压缩包显然包含了一个Android应用程序,该程序使用OpenGL ES来展示一个旋转的立方体,这是学习和理解3D图形编程的一个经典实例。 首先,让我们深入了解OpenGL ES。它是OpenGL标准的轻量级版本,...

    android OpenGL 3D骰子

    在这个"android OpenGL 3D骰子"项目中,我们将探讨如何利用OpenGL ES在Android上实现一个3D骰子的模拟。 首先,要创建一个3D正方体,你需要理解基本的几何形状构建。在OpenGL中,正方体通常由六个矩形面构成,每个...

    android 利用opengl 实现3d图形

    使用android 的3d 图形库 android 使用了行业标准的opengl es api

    基于OpenGL的Android+3D游戏开发技术详解与典型案例(源码)

    本书共分两篇,第一篇介绍了Android 3D游戏开发的基础知识,主要对OpenGL ES的相关内容进行了介绍。  章 名主 要 内 容  第1章 英雄还看今朝—Android简介本章介绍了市场上主流的手机平台,同时也分析了未来手机...

    android3D颜色隧道(openGL-ES)

    在这个"android3D颜色隧道"项目中,开发者利用OpenGL-ES技术创建了一个3D效果的动态隧道,用户可以在Android设备上体验到这种视觉特效。 项目标题"android3D颜色隧道(openGL-ES)"明确指出了应用的核心特点,即它是...

    Android代码-OpenGL3D立方体多纹理贴图源码.zip

    这个“Android代码-OpenGL3D立方体多纹理贴图源码.zip”文件显然包含了实现3D立方体并应用多纹理贴图的示例代码,对于学习Android平台上的3D图形编程非常有帮助。 1. **OpenGL基础知识**:在OpenGL中,图形是通过...

    Android OpenGL ES 2.0学习书籍.rar

    OpenGL ES 2.0是移动设备上的图形处理标准,尤其在Android平台上被广泛用于3D游戏和图形密集型应用的开发。这本书籍“Android 3D游戏开发技术宝典 OpenGL ES2.0学习”深入浅出地介绍了如何利用OpenGL ES 2.0在...

    安卓Android源码——OpenGL 3D立方体多纹理贴图.zip

    OpenGL是计算机图形学中用于渲染2D和3D图像的标准接口,它在Android平台上被广泛用于游戏开发、复杂的用户界面以及各种视觉效果的实现。在Android系统中,我们可以使用OpenGL ES(Embedded Systems的版本)来处理...

    Android下 OpenGL ES 2.0 混合半透明效果demo

    OpenGL ES 2.0是Android平台上用于图形渲染的重要框架,特别是在移动设备上,它为开发者提供了高效、低级别的硬件加速3D图形编程接口。在这个"Android下 OpenGL ES 2.0 混合半透明效果demo"中,我们将探讨如何在...

    android_opengl.rar_Android opengl_android_opengl例子

    Android OpenGL ES提供了丰富的接口,让开发者能够创建复杂的图形应用程序,包括游戏、3D建模和可视化工具等。 这个"android_opengl.rar"压缩包显然包含了多个关于Android平台上的OpenGL ES编程的教学实例,分别以...

Global site tag (gtag.js) - Google Analytics