`
xnewer
  • 浏览: 1902 次
  • 性别: 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()
分享到:
评论
14 楼 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 (level >= _opponetGroup.getChessMan(possiblelocation).level) {
                        nextLocations.add(possiblelocation);
                    }
                }
            }
        }
        return nextLocations;
    }
   
}
13 楼 xnewer 2010-08-24  
public class ChessGroup {
public HashMap<Point, Chess> mapChess = new HashMap<Point, Chess>();
public LinkedList<Chess> listChess = new LinkedList<Chess>();

public void addChess(Chess chess) {
mapChess.put(chess.location, chess);
listChess.add(chess);
Collections.sort(listChess, new Comparator<Chess>() {
public int compare(Chess arg0, Chess arg1) {
return (arg0.level == arg1.level) ? 0
: arg0.level > arg1.level ? 1 : -1;
}
});
}

public void removeChess(Chess chess) {
mapChess.remove(chess.location);
listChess.remove(chess);
}

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

public Chess get(int index){
return listChess.get(index);
}

public Chess getChess(int col, int row) {
Point pt = new Point(col, row);
return mapChess.containsKey(pt) ? mapChess.get(pt) : null;
}

}
12 楼 xnewer 2010-08-20  
package com.lx.CrazyPenguin;

import java.util.LinkedList;

public class Tile {
public int x;
public int y;
public int state;

public static final int EMPTY = 0;
public static final int FILLED = 1;
public static final int KEY_POINT = 2;

public static final int UP = 0;
public static final int DOWN = 1;
public static final int LEFT = 2;
public static final int RIGHT = 3;

public LinkedList<Tile> paths = new LinkedList<Tile>();

public Tile(int x, int y, int state){
this.x = x;
this.y = y;
this.state = state;
}


}
11 楼 xnewer 2010-08-20  
package com.lx.CrazyPenguin;

import java.util.LinkedList;

public class Maze {
private Tile _entrance, _exit;
public Maze(Tile entrance, Tile exit) {
_entrance = entrance;
_exit = exit;
}

public boolean findWay(LinkedList<Tile> way){
way.add(_entrance);
return _findWay(way);
}

private boolean _findWay(LinkedList<Tile> way) {
if(way.isEmpty())
return false;
Tile lastTile = way.getLast();
if (lastTile.paths.isEmpty()) {
way.removeLast();
way.getLast().paths.remove(lastTile);
}else{
way.add(lastTile.paths.getFirst());
}
if(way.getLast() == _exit){
return true;
}else{
_findWay(way);
return false;
}
}

}
10 楼 xnewer 2010-08-06  
public class SimpleAI {
public class Pos{
int x, y;
public Pos(int x, int y){
this.x = x;
this.y = y;
}
}

public class Step{
ArrayList<Pos> pos = new ArrayList<Pos>();
Map4 map = new Map4();
public Step(Map4 map){
this.map = map;
}

public Step(ArrayList<Pos> pos, Map4 map){
this.pos = pos;
this.map = map;
}
}

private int _depth;
private int _depthIndex;

public void getSolution(Map4 map, int depth, ArrayList<int[]> result) {
_depth = depth;
Step step = new Step(map);
while(!step.map.empty()){
ArrayList<Step> possibleSteps = new ArrayList<Step>();
travel(step, possibleSteps);
step = getBest(possibleSteps);
}

for(Pos pos: step.pos){
result.add(new int[]{pos.x, pos.y});
}

}


public void travel(Step currentStep, ArrayList<Step> steps) {
if(++_depthIndex > _depth){
_depthIndex = 0;
return;
}
for (int i = 0; i < 6; i++)
for (int j = 0; j < 6; j++) {
Map4 tmp = currentStep.map.clone();
tmp.trigger(i, j);
ArrayList<Pos> clonePos = new ArrayList<Pos>();
for(Pos pos : currentStep.pos){
clonePos.add(pos);
}
clonePos.add(new Pos(i, j));
Step step = new Step(clonePos, tmp);
steps.add(step);
travel(step, steps);
}
}

private Step getBest(ArrayList<Step> steps) {
int index = -1;
float maxFactor = 0;
for(int i = 0; i< steps.size(); i++){
float factor = steps.get(i).map.calcFactor();
if(factor>maxFactor){
index = i;
maxFactor = factor;
}
}
return steps.get(index);
}
}
9 楼 xnewer 2010-08-06  
import java.util.ArrayList;

public class SimpleAI {
public class Node {
float factor;
int parentX = -1, parentY = -1;
}

private Node[][][] _data;
private int _depth;

public SimpleAI(int depth) {
_depth = depth;
_data = new Node[depth][6][6];
for (int k = 0; k < depth; k++)
for (int i = 0; i < 6; i++)
for (int j = 0; j < 6; j++) {
_data[k][i][j] = new Node();
}
}

private int _depthIndex;

public void travel(Map4 map) {
if (++_depthIndex > _depth)
return;
for (int i = 0; i < 6; i++) {
for (int j = 0; j < 6; j++) {
Map4 tmp = map.clone();
tmp.trigger(i, j);
travel(tmp);
_data[_depthIndex - 1][i][j].factor = tmp.calcFactor();
_data[_depthIndex - 1][i][j].parentX = i;
_data[_depthIndex - 1][i][j].parentY = j;

}
}
}

public void calc(Map4 map, ArrayList<Integer> traceX,
ArrayList<Integer> traceY) {
while (!map.empty()) {
travel(map);
int[] pos = new int[3];
getBest(pos);
Node node = _data[pos[0]][pos[1]][pos[2]];
while (node.parentX != -1) {
node = _data[pos[0] - 1][node.parentX][node.parentY];
}
map.trigger(pos[0], pos[1]);
}
}

private void getBest(int[] pos) {
float max = 0;
for (int k = 0; k < _depth; k++)
for (int i = 0; i < 6; i++)
for (int j = 0; j < 6; j++) {
if (_data[k][i][j].factor > max) {
max = _data[k][i][j].factor;
pos[0] = k;
pos[1] = i;
pos[2] = j;
}
}
}
}
8 楼 xnewer 2010-08-05  
public class CoreAlg {

    public void init() {
    }

    private void travel(Map4 map, int count, int[][] trace) {
        float[][][] factors = new float[count][6][6];
        if(count == 0) return;
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 6; j++) {
                Map4 tmp = map.clone();
                tmp.trigger(i, j);
                travel(tmp, count --, )
                factors[k][i][j] = tmp.calcFactor();
            }
        }

        float max = 0;
        for (int k = 0; k < count; k++) {
            for (int i = 0; i < 6; i++) {
                for (int j = 0; j < 6; j++) {
                    if (factors[k][i][j] > max) {
                        max = factors[k][i][j];
                    }
                }
            }
        }
    }
}
7 楼 xnewer 2010-08-05  
public class Map4 {

    class Node {

        int limit;
        LinkedList<Node> adjvex = new LinkedList<Node>();

        public Node(int limit) {
            this.limit = limit;
        }
    }
    private Node[][] _data = new Node[6][6];

    public void add(int x, int y, int limit) {
        Node node = new Node(limit);
        if (y - 1 >= 0 && _data[x][y - 1] != null) {
            node.adjvex.add(_data[x][y - 1]);
            _data[x][y - 1].adjvex.add(node);
        }
        if (y + 1 <= 6 && _data[x][y + 1] != null) {
            node.adjvex.add(_data[x][y + 1]);
            _data[x][y + 1].adjvex.add(node);
        }
        if (x - 1 >= 0 && _data[x - 1][y] != null) {
            node.adjvex.add(_data[x - 1][y]);
            _data[x - 1][y].adjvex.add(node);
        }
        if (x + 1 <= 6 && _data[x + 1][y] != null) {
            node.adjvex.add(_data[x + 1][y]);
            _data[x + 1][y].adjvex.add(node);
        }

        _data[x][y] = node;
    }

    public void remove(int x, int y) {
        for (Node node : _data[x][y].adjvex) {
            node.adjvex.remove(node);
        }
        _data[x][y] = null;
    }

    @Override
    public Map4 clone() {
        Map4 map4 = new Map4();
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 6; j++) {
                if (_data[i][j] != null) {
                    map4.add(i, j, _data[i][j].limit);
                }
            }
        }
        return map4;
    }

    public void trigger(int x, int y) {
        trigger(_data[x][y]);
    }

    private void trigger(Node node) {
        if (node != null) {
            if (--node.limit == 0) {
                for (Node tmpNode : node.adjvex) {
                    trigger(tmpNode);
                }
                node = null;
            }
        }
    }

    public boolean empty() {
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 6; j++) {
                if (_data[i][j] != null) {
                    return false;
                }
            }
        }
        return true;
    }

    public float calcFactor() {
        int count = 0;
        int limits = 0;
        for (int i = 0; i < 6; i++) {
            for (int j = 0; j < 6; j++) {
                if (_data[i][j] != null) {
                    count++;
                    limits += _data[i][j].limit;
                }
            }
        }
        return (float) ((float) count / limits);
    }
}
6 楼 xnewer 2010-08-05  
public class Map4 {

    class Node {

        int limit;
        LinkedList<Node> adjvex = new LinkedList<Node>();

        public Node(int limit) {
            this.limit = limit;
        }
    }

    private Node[][] _data = new Node[6][6];
   
    public void add(int x, int y, int limit) {
        Node node = new Node(limit);
        if(y-1>=0&&_data[x][y-1]!=null){
            node.adjvex.add(_data[x][y-1]);
            _data[x][y-1].adjvex.add(node);
        }
        if(y+1<=6&&_data[x][y+1]!=null){
            node.adjvex.add(_data[x][y+1]);
            _data[x][y+1].adjvex.add(node);
        }
        if(x-1>=0&&_data[x-1][y]!=null){
            node.adjvex.add(_data[x-1][y]);
            _data[x-1][y].adjvex.add(node);
        }
        if(x+1<=6&&_data[x+1][y]!=null){
            node.adjvex.add(_data[x+1][y]);
            _data[x+1][y].adjvex.add(node);
        }

        _data[x][y] = node;
    }

    public void remove(int x, int y) {
        for (Node node : _data[x][y].adjvex) {
            node.adjvex.remove(node);
        }
        _data[x][y] =null;
    }

    public void trigger(Node node){
        if (node != null) {
            if (--node.limit == 0) {
                for (Node tmpNode : node.adjvex) {
                    trigger(tmpNode);
                }
                node = null;
            }
        }
    }
   
    public void f(){
        while(!empty(_data)){
            int[] pos = new int[2];
            travel(2, _data, pos);
        }
    }

    private boolean empty(Node[][] data){
        for(int i = 0; i< 6; i++)
            for(int j = 0; j< 6; j++){
                if(data[i][j]!=null)
                    return false;
            }
        return true;
    }

    private void copy(Node[][] src, Node[][] dst){
            for(int i = 0; i< 6; i++)
                for(int j = 0; j< 6; j++){
                    dst[i][j] = src[i][j].clone();
                }
    }
   
    private void travel(int count, Node[][] data, int[] bestPos){
        float[][][] factors = new float[count][6][6];
        for(int k = 0; k < count; k++){
            for(int i = 0; i< 6; i++)
                for(int j = 0; j< 6; j++){
                    if(data[i][j]!=null){
                        trigger(data[i][j]);
                        factors[k][i][j] = calcFactor();
                    }
                }
        }
        float max = 0;
        for(int k = 0; k< count; k++)
        for(int i = 0; i< 6; i++)
            for(int j = 0; j< 6; j++){
                if(factors[k][i][j]>max)
                {
                    max = factors[k][i][j];
                    bestPos[0] = i;
                    bestPos[1] = j;
                }
            }
    }

    public float calcFactor(){
        int count =0;
        int limits = 0;
        for(int i = 0; i< 6; i++)
            for(int j = 0; j< 6; j++){
                if(_data[i][j]!=null){
                    count++;
                    limits += _data[i][j].limit;
                }
            }
        return (float)((float)count/limits);
    }
}
5 楼 xnewer 2010-08-05  
public class Map4 {

    class Node {

        int limit;
        LinkedList<Node> adjvex = new LinkedList<Node>();

        public Node(int limit) {
            this.limit = limit;
        }
    }

    private Node[][] _data = new Node[6][6];
   
    public void add(int x, int y, int limit) {
        Node node = new Node(limit);
        if(y-1>=0&&_data[x][y-1]!=null)
            node.adjvex.add(_data[x][y-1]);
        if(y+1<=6&&_data[x][y+1]!=null)
            node.adjvex.add(_data[x][y+1]);
        if(x-1>=0&&_data[x-1][y]!=null)
            node.adjvex.add(_data[x-1][y]);
        if(x+1<=6&&_data[x+1][y]!=null)
            node.adjvex.add(_data[x+1][y]);

        _data[x][y] = node;
    }

    public void remove(int x, int y) {
        for (Node node : _data[x][y].adjvex) {
            node.adjvex.remove(node);
        }
        _data[x][y] =null;
    }

    public void trigger(Node node){
        if (node != null) {
            if (--node.limit == 0) {
                for (Node tmpNode : node.adjvex) {
                    trigger(tmpNode);
                }
                node = null;
            }
        }
    }
   
    public void f(){
        while(!empty(_data)){
            int[] pos = new int[2];
            travel(2, _data, pos);
        }
    }

    private boolean empty(Node[][] data){
        for(int i = 0; i< 6; i++)
            for(int j = 0; j< 6; j++){
                if(data[i][j]!=null)
                    return false;
            }
        return true;
    }

    private void travel(int count, Node[][] data, int[] bestPos){
        float[][][] factors = new float[count][6][6];
        for(int k = 0; k < count; k++){
            for(int i = 0; i< 6; i++)
                for(int j = 0; j< 6; j++){
                    if(data[i][j]!=null){
                        trigger(data[i][j]);
                        factors[k][i][j] = calcFactor();
                    }
                }
        }
        float max = 0;
        for(int k = 0; k< count; k++)
        for(int i = 0; i< 6; i++)
            for(int j = 0; j< 6; j++){
                if(factors[k][i][j]>max)
                {
                    max = factors[k][i][j];
                    bestPos[0] = i;
                    bestPos[1] = j;
                }
            }
    }

    public float calcFactor(){
        int count =0;
        int limits = 0;
        for(int i = 0; i< 6; i++)
            for(int j = 0; j< 6; j++){
                if(_data[i][j]!=null){
                    count++;
                    limits += _data[i][j].limit;
                }
            }
        return (float)((float)count/limits);
    }
}
4 楼 xnewer 2010-08-04  
public class Map4 {
class Node {
int limit;
LinkedList<Node> adjvex = new LinkedList<Node>();

public Node(int limit) {
this.limit = limit;
}
}

private LinkedList<Node> _nodes = new LinkedList<Node>();

public void add(Node node) {
_nodes.add(node);
}

public void remove(Node node) {
for (Node tmpNode : node.adjvex) {
tmpNode.adjvex.remove(node);
}
_nodes.remove(node);
}

public void addLink(Node node1, Node node2) {
node1.adjvex.add(node2);
node2.adjvex.add(node1);
}

public void trigger(Node node){
if (node != null) {
if (--node.limit == 0) {
for(Node tmpNode:node.adjvex){
trigger(tmpNode);
}
remove(node);
}
}
}

}
3 楼 xnewer 2010-07-30  
http://blog.chinaunix.net/u/20947/showart_1964829.html
2 楼 xnewer 2010-07-29  
<HTML>
<BODY>
<form action="/add" method="post">
      <input type="text" name="email"><br>
      <div><input type="text" name="level"><br>
      <div><input type="text" name="lifes"><br>
      <div><input type="submit" value="add"><br>
    </form>
</BODY>
</HTML>
1 楼 xnewer 2010-07-29  
<html>
  <body>
  <TABLE>
    {% for line in list %}
    <TR>
<TD>{{ line.user}}</TD>
<TD>{{ line.level}}</TD>
<TD>{{ line.lifes}}</TD>
<TD>{{ line.date}}</TD>
    </TR>
    {% endfor %} 
  </TABLE>
  </body>
</html>

相关推荐

    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