Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
Adding WordList class
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Silveira authored and Michael Silveira committed Sep 12, 2010
1 parent 4cc2c20 commit fe0c72e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
Empty file added output.html
Empty file.
34 changes: 31 additions & 3 deletions src/im/crate/bridge/clutter/Clutter.java
@@ -1,9 +1,12 @@
package im.crate.bridge.clutter;

import im.crate.bridge.clutter.Clutter.Word;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Random;

Expand Down Expand Up @@ -57,7 +60,7 @@ public class Clutter extends BaseGameActivity implements IAccelerometerListener
private Font mFont;
private Font mEnglishFont;
private PhysicsWorld mPhysicsWorld;
private ArrayList<String[]> wordlist = new ArrayList<String[]>();
private ArrayList<String[]> stringlist = new ArrayList<String[]>();
private HashMap<String, String[]> inscene = new HashMap<String,String[]>();
private String currentWord;
private Word currentWordObj;
Expand Down Expand Up @@ -108,14 +111,39 @@ public void onLoadResources() {
String line;
while((line = wordrdr.readLine()) != null)
{
wordlist.add(new String[] {line.substring(0, line.indexOf(":")), line.substring(line.indexOf(":")+1)});
stringlist.add(new String[] {line.substring(0, line.indexOf(":")), line.substring(line.indexOf(":")+1)});
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

class WordList<Word> extends ArrayList<Word> {

public WordList(int number_of_words){
/*for (int i=0; i<number_of_words; i++){
Vector2 posVector = new Vector2(100, 100);
Word newWord = new Word(mFont, pair[1], posVector, scene);
this.add(newWord);
}*/
}
public void jumble(){
int lockedUpto = 10;

ArrayList<Word> dummyList = new ArrayList<Word>();
for (int i = lockedUpto; i<this.size(); i++){
dummyList.add(this.get(i));
}

Collections.shuffle(dummyList);

this.removeRange(lockedUpto, this.size());
this.addAll(dummyList);
}

}

class Word {
Text txtShape;
Body txtBody;
Expand Down Expand Up @@ -225,7 +253,7 @@ public Scene onLoadScene() {
int total_words = 1;
for (int i = 0; i < total_words; i++)
{
String[] pair = wordlist.get(rand.nextInt(wordlist.size()));
String[] pair = stringlist.get(rand.nextInt(stringlist.size()));
Random rand2 = new Random();

//float x = rand2.nextInt(CAMERA_WIDTH - 20)+10;
Expand Down

0 comments on commit fe0c72e

Please sign in to comment.