GithubHelp home page GithubHelp logo

iforgot's Introduction

IForgot

Icon made by Vectors Market from www.flaticon.com 玩法解說

畫面中總共有八張卡片,上三下五,上排為題目,下排為答題區。

hgz2v7b

一開始上排會顯示題目,玩家須記下圖片順序,幾秒後題目會覆蓋,玩家依序選擇答案。

bkzt0yr

答題三次失敗則遊戲結束。

Icon made by flaticon from www.flaticon.com 程式碼

這個遊戲主要的程式是在於題目的亂數,需要產生不重複的三個亂數,我採用了洗牌法。
  1. 假設現在有一個陣列,大小為 6 ,一開始先依序存入 A、B、C、D、E、F ,上方數字為陣列 index 。4yl58jm
  2. 用亂數取兩個 0 ~ 5 的值,決定兩張要交換的 index ,交換後如下圖,兩張牌只有內容改變, index 不變。 cukworo
  3. 再度用亂數取兩個 0 ~ 5 的值,做交換。 q5bpiwp qqa9byd
  4. 多交換幾次後,就可以得到一個不重複的亂數,此為洗牌法。nr5ajc7
程式碼如下:
string Array[6]={"A", "B", "C", "D", "E", "F"};
int index1, index2;
string temp;
for(int i = 0; i < 100; i++){ // 代表交換了 100 次
	index1 = rand() % 6; // 0 ~ 5
	index2 = rand() % 6;
// 兩者內容交換
temp = Array[index1];
Array[index1] = Array[index2];
Array[index2] = temp;

}

tpodion 遊戲素材

tpodion 參考資料

iforgot's People

Contributors

celine-yeh avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.