h5拼圖游戲源碼
Ⅰ 怎麼運行 html5游戲的源代碼
HTML5游戲是通過html+javascript+css技術開發的游戲,屬於網頁游戲,可以運行在HTML5的網頁瀏覽器中。
運行HTML5游戲,需要一個支持HTML5的網頁瀏覽器,比如IE10或11,google的chrome瀏覽器,火狐firefox,網路瀏覽器,或者QQ瀏覽器,獵豹瀏覽器等CHROME內核的瀏覽器。
下載的HTML5游戲文件解壓後,文件夾中會有一個後綴為html或者htm的文件,應該是在根目錄下一般以index.html命名。其他文件可能有js後綴,css後綴,或者圖片,請保持相對位置不能動。
然後按下面方式運行那個html文件:
方法1:
打開瀏覽器,將html文件拖拽到瀏覽器中。
方法2:
在文件夾中選中html文件,點右鍵,在菜單選擇「打開方式」,然後選擇火狐、Chrome瀏覽器、或者上述所說的網路瀏覽器、QQ瀏覽器、獵豹瀏覽器即可。
Ⅱ 1200分跪求JAVA數字拼圖游戲源代碼!
1:
import java.io.IOException;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
// 華容道原理的拼圖游戲。 利用輕組建的套用。
import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Choice;
import java.awt.Color;
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class MyMainFrame extends JFrame implements ActionListener {
/**
*
*/
private static final long serialVersionUID = 1L;
MyCanvas myCanvas;
JPanel panelNorth,panelPreview;
Button start,preview,set;
Container container;
public MyMainFrame() {//初使化
container=this.getContentPane();
start=new Button("開始");
start.addActionListener(this);
preview=new Button("預覽");
preview.addActionListener(this);
set = new Button("設置");
set.addActionListener(this);
panelPreview=new JPanel();
panelPreview.setLayout(null);
Icon icon=new ImageIcon ("images/pic_"+MyCanvas.pictureID+".jpg");
JLabel label=new JLabel(icon);
label.setBounds(0,0,400,400);
panelPreview.add(label);
panelNorth=new JPanel();
panelNorth.setBackground(Color.yellow);
panelNorth.add(start);
panelNorth.add(preview);
panelNorth.add(set);
myCanvas=new MyCanvas();
container.add(myCanvas,BorderLayout.CENTER);
container.add(panelNorth,BorderLayout.NORTH);
this.setTitle("成型拼圖小游戲-1212");
this.setLocation(300,200);
this.setSize(408,465);
this.setResizable(false);
this.setVisible(true);
this.setDefaultCloseOperation(3);
} //end of 初始化 構造函數
public void actionPerformed(ActionEvent e) {
Button button=(Button)e.getSource();
if(button==start){
myCanvas.Start();
}else if(button==preview){
if(button.getLabel()=="預覽"){
container.remove(myCanvas);
container.add(panelPreview);
panelPreview.updateUI();
container.repaint();
button.setLabel("返回");
}else{
container.remove(panelPreview);
container.add(myCanvas);
container.repaint();
button.setLabel("預覽");
}
}else if(button==set){
Choice pic = new Choice();
//pic.add("QQ");
pic.add("美女");
int i=JOptionPane.showConfirmDialog(this,pic,"選擇圖片", JOptionPane.OK_CANCEL_OPTION);
//使用選擇對話框來進行選擇圖片。
if(i==JOptionPane.YES_OPTION){
MyCanvas.pictureID=pic.getSelectedIndex()+5;
myCanvas.reLoadPictrue();
Icon icon=new ImageIcon("images/pic_"+MyCanvas.pictureID+".jpg");
JLabel label=new JLabel(icon);
label.setBounds(0,0,400,400);
panelPreview.removeAll();
panelPreview.add(label);
panelPreview.repaint();
}
}
}
public static void main(String[] args) throws UnsupportedAudioFileException, LineUnavailableException, IOException
{
new MyMainFrame();
} //end of main
}
2:
import java.awt.Rectangle;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
public class MyCanvas extends JPanel implements MouseListener
{
/**
*
*/
private static final long serialVersionUID = 1L;
boolean hasAddActionListener=false;//設置方格的動作監聽器的標志位,TRUE為已經添加上動作事件
Cell cell[];//定義方格
Rectangle cellNull;//定義空方格區域 是一個矩形類
public static int pictureID=4;// 當前選擇的圖片代號
public MyCanvas() {
this.setLayout(null);
this.setSize(400,400);
cellNull=new Rectangle(300,300,100,100);//空方格區域在第三行每三列
cell=new Cell[16];
Icon icon;
for (int i = 0; i < 4; i++) {
for(int j=0;j<4;j++){
icon=new ImageIcon("images/pic_"+pictureID+"_"+(i*4+j+1)+".jpg");
cell[i*4+j]=new Cell(icon);
cell[i*4+j].setLocation(j*100,i*100);
this.add(cell[i*4+j]);
}
}
this.remove(cell[15]);//移除最後一個多餘的方格
} //放置9張小圖片並且移調最後一張
public void reLoadPictrue(){//當選擇其它圖形進行拼圖時,需重新載入新圖片
Icon icon;
for (int i = 0; i < 4; i++) {
for(int j=0;j<4;j++){
icon=new ImageIcon("images/pic_"+pictureID+"_"+(i*4+j+1)+".jpg");
cell[i*4+j].setIcon(icon);
}
}
}
public boolean isFinish(){//判斷是否拼合成功
for(int i=0;i<15;i++)
{ int x=cell[i].getBounds().x;
int y=cell[i].getBounds().y;
if(y/100*4+x/100!=i)
return false;
} //end of for
return true;
}
public void Start(){//對方格進行重新排列,打亂順序
while(cell[0].getBounds().x<=100&&cell[0].getBounds().y<=100){//當第一個方格距左上角較近時
int x=cellNull.getBounds().x;
int y=cellNull.getBounds().y;
int direction=(int)(Math.random()*4);//產生0-4,對應空方格的上下左右移動
if(direction==0){//空方格左移動,與左側方格互換位置,左側方格右移動
x-=100;
if(test(x,y)){
for(int j=0;j<15;j++){
if((cell[j].getBounds().x==x)&&(cell[j].getBounds().y==y)){//依次尋找左側的按鈕
cell[j].move("RIGHT",100);
cellNull.setLocation(x,y);
break;//找到後跳出for循環
}
}
}
}else if(direction==1){//RIGHT
x+=100;
if(test(x,y)){
for(int j=0;j<15;j++){
if((cell[j].getBounds().x==x)&&(cell[j].getBounds().y==y)){
cell[j].move("LEFT",100);
cellNull.setLocation(x,y);
break;
}
}
}
}else if(direction==2){//UP
y-=100;
if(test(x,y)){
for(int j=0;j<15;j++){
if((cell[j].getBounds().x==x)&&(cell[j].getBounds().y==y)){
cell[j].move("DOWN",100);
cellNull.setLocation(x,y);
break;
}
}
}
}else{//DOWN
y+=100;
if(test(x,y)){
for(int j=0;j<15;j++){
if((cell[j].getBounds().x==x)&&(cell[j].getBounds().y==y)){
cell[j].move("UP",100);
cellNull.setLocation(x,y);
break;
}
}
}
}
}
if(!hasAddActionListener)//如果尚未添加動作事件,則添加
for(int i=0;i<15;i++)//為第個方格添加動作事件,這樣單擊按鈕就能移動了
cell[i].addMouseListener(this);
hasAddActionListener=true;
}
private boolean test(int x,int y){
if((x>=0&&x<=200)||(y>=0&&y<=200))
return true;
else
return false;
}
public void mouseClicked(MouseEvent e) { }
public void mouseEntered(MouseEvent e) { }
public void mouseExited(MouseEvent e) { }
public void mouseReleased(MouseEvent e) { }
public void mousePressed(MouseEvent e) {
//方格的滑鼠事件,因為用到了MyCanvas中的一些方法,因此沒有在Cell類中處理滑鼠事件
Cell button=(Cell)e.getSource();
int x1=button.getBounds().x;//得到所單擊方格的坐標
int y1=button.getBounds().y;
int x2=cellNull.getBounds().x;//得到空方格的坐標
int y2=cellNull.getBounds().y;
if(x1==x2&&y1-y2==100)//進行比較,如果滿足條件則進行交換
button.move("UP",100);
else if(x1==x2&&y1-y2==-100)
button.move("DOWN",100);
else if(x1-x2==100&y1==y2)
button.move("LEFT",100);
else if(x1-x2==-100&&y1==y2)
button.move("RIGHT",100);
else
return;//不滿足就不進行任何處理
cellNull.setLocation(x1,y1);
this.repaint();
if(this.isFinish()){//進行是否完成的判斷
JOptionPane.showMessageDialog(this,"景鋒恭喜你完成拼圖,加油!想繼續下一關么?");
for(int i=0;i<15;i++)
cell[i].removeMouseListener(this);//如果已完成,撤消滑鼠事件,滑鼠單擊方格不在起作用
hasAddActionListener=false;
}
}
}
3:
import javax.swing.Icon;
import javax.swing.JButton;
public class Cell extends JButton {
/**
*
*/
private static final long serialVersionUID = 1L;
Cell(Icon icon){//實際為ICON
super(icon);
this.setSize(100,100);
}
public void move(String direction,int sleep){//方格的移動
if(direction=="UP"){
this.setLocation(this.getBounds().x,this.getBounds().y-100);
}else if(direction=="DOWN"){
this.setLocation(this.getBounds().x,this.getBounds().y+100);
}else if(direction=="LEFT"){
this.setLocation(this.getBounds().x-100,this.getBounds().y);
}else{
this.setLocation(this.getBounds().x+100,this.getBounds().y);
}
}
}
Ⅲ 我愛h5游戲源碼的免費源碼都有哪些啊有好多都沒找到在哪
貼吧里看見個蛇蛇大作戰的是免費的,http://tieba..com/p/4954128281,網站最近更新的貌似都是免費的。
Ⅳ 有了h5游戲源碼怎麼用
1、首先打開任意的一個網站,點擊右上角三條橫杠的按鈕。
2、其次點擊工具選項。點擊查看源代碼。
3、最後輸入代碼即可。
Ⅳ 怎麼運行 html5游戲的源代碼
1、打開任意一個網站,根據自己的需要選擇。
Ⅵ 淘寶買的h5游戲源碼 改造的 算侵權嗎
不違法,但有的違法有的賣家賣的是別人在用的有版權的源碼,這他本身就不是合法的.只是淘寶沒力度去查.你買了用的話,也不算合法,人家網站是可以告你的.如果你買了不用,是不違法的.用就違法.當然賣家也有責任.只要有投訴,淘寶會處理它.不過也有的是程序員自己賣自己開發的產品的,這類是正規的,價格稍高些,但是原創的,可以大膽的用.總之要找原創沒版權的用.這樣你才可以安心,也不會有後顧之憂
Ⅶ 什麼地方有出售H5游戲源碼的
出售H5游戲源碼的很多,關鍵看你要H5游戲源碼想做什麼了,自己研究研究玩的話隨便到網站論壇找一找就好了,如果想自己運營H5游戲,開發H5游戲的話建議還是選個靠譜的公司去買,一般找來的源碼很難滿足運營的功能,買的話去網上搜一下溪谷軟體,專做H5游戲開發,游戲平台搭建這塊兒的。