Help with falling letter cubes and word detection in Processing

final int MENU_WIDTH = 420;
final int MENU_HEIGHT = 380;
final int ACCOUNT_BUTTON_WIDTH = 120;
final int ACCOUNT_BUTTON_HEIGHT = 42;
final int ACCOUNT_BUTTON_MARGIN = 25;
final int ACCOUNT_BUTTON_GAP = 15;
final color BACKGROUND_COLOR = #121623;
final color BORDER_COLOR = #5A648C;
final color TITLE_COLOR = #FFD250;
final color TEXT_COLOR = #EBEBEB;
final color SELECTED_COLOR = #FFD250;
final color INSTRUCTION_COLOR = #C8C8C8;
final color BUTTON_COLOR = #262C41;
final color BUTTON_HOVER_COLOR = #5A648C;
final color BUTTON_BORDER_COLOR = #FFD250;
final String[] MENU_OPTIONS = { "New Game", "Options", "Exit" };
final String MENU = "menu";
final String NAME_ENTRY = "name_entry";
final String GUEST = "guest";
PFont titleFont;
PFont optionFont;
PFont accountButtonFont;
PFont instructionFont;
PFont arrowFont;
int menuX, menuY;
int selectedOption = 0;
String currentScreen = MENU;
String playerName = "";
void settings() {
  
  size(900, 650);
}
void setup() {
  frameRate(60);
  textAlign(CENTER, CENTER);
  titleFont = loadGameFont("AromaVintage-Regular.otf", 56);
  optionFont = loadGameFont("Mooligat-Demo-BF689966f7263ea.otf", 32);
  accountButtonFont = loadGameFont("Mooligat-Demo-BF689966f7263ea.otf", 22);
  instructionFont = createFont("Serif", 18);
  arrowFont = createFont("Consolas Bold", 42);
  menuX = (width - MENU_WIDTH) / 2;
  menuY = (height - MENU_HEIGHT) / 2;
}
void draw() {
  background(BACKGROUND_COLOR);
  if (currentScreen.equals(MENU)) {
    drawMenu();
    drawAccountButton("Login", loginButtonX(), ACCOUNT_BUTTON_MARGIN);
    drawAccountButton("Register", registerButtonX(), ACCOUNT_BUTTON_MARGIN);
  } else if (currentScreen.equals(NAME_ENTRY)) {
    drawNameEntry();
  } else if (currentScreen.equals(GUEST)) {
    drawGuestPage();
  }
}
PFont loadGameFont(String filename, float fontSize) {
  String[] candidates = {
    sketchPath("data/assets/fonts/" + filename),
    sketchPath("assets/fonts/" + filename)
  };
  for (String path : candidates) {
    if (new File(path).isFile()) {
      return createFont(path, fontSize);
    }
  }
  return createFont("Serif", fontSize);
}
void drawCenteredText(PFont font, String message, color textColor, float x, float y) {
  textFont(font);
  fill(textColor);
  textAlign(CENTER, CENTER);
  text(message, x, y);
}
void drawMenu() {
  drawMenuBorder();
  drawCenteredText(titleFont, "Crazy Words", TITLE_COLOR, width / 2, menuY + 65);
  int firstOptionY = menuY + 160;
  for (int index = 0; index < MENU_OPTIONS.length; index++) {
    float optionY = firstOptionY + index * 65;
    color optionColor = (index == selectedOption) ? SELECTED_COLOR : TEXT_COLOR;
    drawCenteredText(optionFont, MENU_OPTIONS[index], optionColor, width / 2, optionY);
    if (index == selectedOption) {
      textFont(arrowFont);
      float halfTextWidth = textWidth(MENU_OPTIONS[index]) / 2.0;
      drawCenteredText(arrowFont, ">", SELECTED_COLOR, width / 2 - halfTextWidth - 40, optionY);
      drawCenteredText(arrowFont, "<", SELECTED_COLOR, width / 2 + halfTextWidth + 40, optionY);
    }
  }
}
void drawMenuBorder() {
  noFill();
  stroke(BORDER_COLOR);
  strokeWeight(3);
  rect(menuX, menuY, MENU_WIDTH, MENU_HEIGHT, 20);
  strokeWeight(1);
}
void drawAccountButton(String label, int x, int y) {
  boolean hovered = pointInRect(mouseX, mouseY, x, y, ACCOUNT_BUTTON_WIDTH, ACCOUNT_BUTTON_HEIGHT);
  fill(hovered ? BUTTON_HOVER_COLOR : BUTTON_COLOR);
  stroke(BUTTON_BORDER_COLOR);
  strokeWeight(2);
  rect(x, y, ACCOUNT_BUTTON_WIDTH, ACCOUNT_BUTTON_HEIGHT, 10);
  strokeWeight(1);
  drawCenteredText(accountButtonFont, label, TEXT_COLOR,
    x + ACCOUNT_BUTTON_WIDTH / 2.0, y + ACCOUNT_BUTTON_HEIGHT / 2.0);
}
void drawNameEntry() {
  drawMenuBorder();
  drawCenteredText(optionFont, "Enter your name", TITLE_COLOR, width / 2, menuY + 80);
  int inputWidth = 320;
  int inputHeight = 60;
  int inputX = width / 2 - inputWidth / 2;
  int inputY = menuY + 165 - inputHeight / 2;
  noFill();
  stroke(BORDER_COLOR);
  strokeWeight(2);
  rect(inputX, inputY, inputWidth, inputHeight, 8);
  strokeWeight(1);
  String cursor = ((millis() / 500) % 2 == 0) ? "_" : "";
  String displayedName = playerName.length() > 0 ? playerName + cursor : "Guest name" + cursor;
  color displayedColor = playerName.length() > 0 ? TEXT_COLOR : INSTRUCTION_COLOR;
  drawCenteredText(optionFont, displayedName, displayedColor, width / 2, menuY + 165);
  drawCenteredText(instructionFont, "Press Enter to continue", INSTRUCTION_COLOR, width / 2, menuY + 245);
  drawCenteredText(instructionFont, "Press Esc to return to the menu", INSTRUCTION_COLOR, width / 2, menuY + 280);
}
void drawGuestPage() {
  drawCenteredText(titleFont, "Welcome, " + playerName + "!", TITLE_COLOR, width / 2, height / 2 - 30);
  drawCenteredText(optionFont, "You are playing as a guest.", TEXT_COLOR, width / 2, height / 2 + 40);
}
void keyPressed() {
  if (currentScreen.equals(MENU)) {
    handleMenuKeyPressed();
  } else if (currentScreen.equals(NAME_ENTRY)) {
    handleNameEntryKeyPressed();
  } else if (currentScreen.equals(GUEST) && key == ESC) {
    key = 0; 
    currentScreen = MENU;
  }
}
void handleMenuKeyPressed() {
  if (key == CODED && keyCode == UP) {
    selectedOption = (selectedOption - 1 + MENU_OPTIONS.length) % MENU_OPTIONS.length;
  } else if (key == CODED && keyCode == DOWN) {
    selectedOption = (selectedOption + 1) % MENU_OPTIONS.length;
  } else if (key == ENTER || key == RETURN) {
    executeMenuAction(selectedOption);
  }
}
void handleNameEntryKeyPressed() {
  if (key == ESC) {
    key = 0; 
    currentScreen = MENU;
  } else if (key == BACKSPACE) {
    if (playerName.length() > 0) {
      playerName = playerName.substring(0, playerName.length() - 1);
    }
  } else if (key == ENTER || key == RETURN) {
    String trimmedName = trim(playerName);
    if (trimmedName.length() > 0) {
      playerName = trimmedName;
      currentScreen = GUEST;
    }
  } else if (key != CODED && !Character.isISOControl(key) && playerName.length() < 16) {
    playerName += key;
  }
}
void mouseMoved() {
  if (!currentScreen.equals(MENU)) {
    return;
  }
  for (int index = 0; index < MENU_OPTIONS.length; index++) {
    if (pointInOptionRect(mouseX, mouseY, index)) {
      selectedOption = index;
      return;
    }
  }
}
void mousePressed() {
  if (!currentScreen.equals(MENU) || mouseButton != LEFT) {
    return;
  }
  if (pointInRect(mouseX, mouseY, loginButtonX(), ACCOUNT_BUTTON_MARGIN,
      ACCOUNT_BUTTON_WIDTH, ACCOUNT_BUTTON_HEIGHT)) {
    println("Login button clicked");
  } else if (pointInRect(mouseX, mouseY, registerButtonX(), ACCOUNT_BUTTON_MARGIN,
      ACCOUNT_BUTTON_WIDTH, ACCOUNT_BUTTON_HEIGHT)) {
    println("Register button clicked");
  } else {
    for (int index = 0; index < MENU_OPTIONS.length; index++) {
      if (pointInOptionRect(mouseX, mouseY, index)) {
        selectedOption = index;
        executeMenuAction(selectedOption);
        return;
      }
    }
  }
}
void executeMenuAction(int option) {
  if (option == 0) {
    playerName = "";
    currentScreen = NAME_ENTRY;
  } else if (option == 1) {
    println("Options selected");
  } else if (option == 2) {
    exit();
  }
}
boolean pointInOptionRect(float px, float py, int optionIndex) {
  int optionWidth = 250;
  int optionHeight = 50;
  int optionX = width / 2 - optionWidth / 2;
  int optionY = menuY + 160 + optionIndex * 65 - optionHeight / 2;
  return pointInRect(px, py, optionX, optionY, optionWidth, optionHeight);
}
boolean pointInRect(float px, float py, float x, float y, float w, float h) {
  return px >= x && px <= x + w && py >= y && py <= y + h;
}
int loginButtonX() {
  return width - ACCOUNT_BUTTON_WIDTH - ACCOUNT_BUTTON_MARGIN;
}
int registerButtonX() {
  return loginButtonX() - ACCOUNT_BUTTON_WIDTH - ACCOUNT_BUTTON_GAP;
}

Hello everyone,

I am building a word game in Processing. I have already created the starting menu, and I now want to implement the gameplay.

My idea is:

  • Random cubes fall downward on the Y axis.
  • Each cube contains one letter.
  • The player selects or arranges the falling cubes to form a word.
  • If the formed word matches the required/correct word, the cubes should explode or disappear.
  • After that, the score should increase, or the game should advance to the next level.

I would appreciate guidance on how to structure this. In particular, I need help with:

  1. Creating and storing multiple falling cubes.
  2. Giving each cube a random letter and downward speed.
  3. Detecting when a cube reaches the bottom of the screen.
  4. Letting the player select cubes and build a word from their letters.
  5. Checking whether the created word is correct.
  6. Creating a simple explosion/disappearing animation.
  7. Updating the score and changing levels.

I am still learning Processing, so examples or suggestions for the correct class structure would be very helpful. Should I create a Cube class, a WordManager class, and a Game class?

Thank you in advance,

Best Regards,

Alex

Hi Alex welcome to the forum.

Although you only have 223 lines of code so far it will soon get much, much bigger so your first priority should be to organise the code into tabs otherwise you will be swimming though thousands of code lines looking for the bit that needs editing.

For a start you could create a second tab called constants and put in all your final constants and global variables, that’s lines 1 - 28

The next thing to consider is that your game can be split into sections / modes

  • START MENU - display menu and get players name you have done this bit
  • INSTRUCTIONS - tells the user how to play the game
  • PLAY - the user plays a level
  • CHANGE LEVEL - user successfully finishes a level level score is displayed and option to start next level
  • GAME_OVER - display final score and invite to play a new game

The simple sketch below shows what I mean. It has the advantage that each mode can be written and tested independently of the others. Simply change the mode in setup to work on another mode. Each mode can have its own tab so it is easy to find and edit your vode.

This is just a start as I would definitely create a class for the letter cube and designing the class code is very important to make the game play easier. I can help with that later if you want.

You are at the start of a challenging but exciting project.
:smile:

final int START_MENU = 101;
final int INSTRUCTIONS = 102;
final int PLAY =103;
final int CHANGE_LEVEL = 104;
final int GAME_OVER = 105;

int mode;

void settings() {
  size(640, 480);
}

void setup() {
  textSize(30);
  textAlign(CENTER, CENTER);
  mode = START_MENU;
}

void draw() {
  switch(mode) {
  case START_MENU:
    drawStartMenu();
    break;
  case INSTRUCTIONS:
    drawInstructions();
    break;
  case PLAY:
    drawPlay();
    break;
  case CHANGE_LEVEL:
    drawChangeLevel();
    break;
  case GAME_OVER:
    drawGameOver();
    break;
  }
}

void keyTyped() {
  switch(mode) {
  case START_MENU:
    mode=INSTRUCTIONS;
    break;
  case INSTRUCTIONS:
    mode=PLAY;
    break;
  case PLAY:
    mode = CHANGE_LEVEL;
    break;
  case CHANGE_LEVEL:
    mode= GAME_OVER;
    break;
  case GAME_OVER:
    mode = START_MENU;
    break;
  }
}

void drawStartMenu() {
  background(0);
  fill(255, 255, 0);
  text("Start Menu\npress any key to see instructions", 0, 0, width, height);
}

void drawInstructions() {
  background(200, 200, 255);
  fill(0, 0, 60);
  text("Instructions\npress any key to play", 0, 0, width, height);
}

void drawPlay() {
  background(0, 200, 200);
  fill(0, 0, 60);
  text("Playing\npress any key to end level", 0, 0, width, height);
}

void drawChangeLevel() {
  background(240, 0, 240);
  fill(60, 0, 60);
  text("Level Complete\npress any key to end game", 0, 0, width, height);
}

void drawGameOver() {
  background(0);
  fill(255);
  text("Game Over\npress any key to see start again", 0, 0, width, height);
}

Hey and welcome to the forum!

Great to have you here.

What a lovely project!

I have a question:

  1. It reminds me of Tetris so you can steer the falling letter to place it correctly?
  2. Below is a stack of letters that have already landed?
  3. The resulting word can be horizontal and vertical?
  4. Only one letter falls or a word?

Greetings, Chris

Thank you both very much for the warm welcome and for taking the time to give such thoughtful advice. I really appreciate the encouragement and the suggestions about organizing the sketch into tabs and modes. I have now restructured my project into constants.pde, game_objects.pde, screens.pde, and input.pde, which already makes it much easier to understand and extend.

About the gameplay questions:

  1. Yes, the player should be able to steer the falling letter. In my current version, Left/Right move it horizontally, Down moves it down one cell, and Space performs a hard drop.
  2. Yes, the letters at the bottom are intended to be a stack of letters that have already landed.
  3. At the moment, the player forms the target word by typing its letters in order from settled letter blocks. My next step is to add proper horizontal and vertical word detection in the grid, so the board position of letters will matter as well.
  4. Only one letter falls at a time, but it falls continuously on a timer. The game should continue in real time even while the player is thinking, moving a letter, or typing. It is not intended to be turn-based.

For replayability, I would like each new game to select different words, distractor letters, falling-letter positions, speeds, and difficulty levels. The score should reward completed words and perhaps longer words or faster completion. I would also like the board to become gradually more challenging as the game continues.

I am still learning, so I would be grateful for advice about the best way to implement horizontal/vertical word detection without making the project too complicated. Thank you again!

Best Regards,

Alex

Hello!

Great progress here!

There are several ways of doing it.

One way:

copy the letter after falling into a 2D grid:

String[][] gameBoard;

Then you can after every letter make a join() command over all rows and columns (join() worked for me not in both cases)

and use if (line.contains(englishWord)) {..........}

You need a list of English Words where you get englishWord from. Google “10000 most frequent english words” or something. Maybe you can find a list for crossword puzzles.

  • Besides, the frequency distribution (how often does each letter appear) of each letter must be different (like in the game Scrabble), e must fall more often than q.

Chrisir

Ideas:

  • You can also have a blank tile / wild tile (wildcard / joker) like in Scrabble which can represent ANY letter.
  • You can order the 10000 english word list by LENGTH. When the player achieves oldschool you want to check for oldschool first and only later for school and old.

Do you know Tetris?

  • Apart from single letters you could also use tetris forms that contain letters (which must be part of existing english words)

You have already discovered that organising your code into seperate tabs has helped you, the next step would be to design and create classes to represent your game ‘artifacts’ .

I cannot stress enough that using classes and objects can simplify the creation of a complex sketch like this one making it so much easier to achieve your aims. In fact I would not consider trying to create this game without classes and objects (in computing this is called object orientation)

I recommend that you start with two classes

  1. Tile represents a single letter tile which
  2. Board stores the tiles already ‘landed’ and can be searched for words etc.

At the moment you have the tiles moving one cell-position at a time do you want smooth vertical animation (pixel level)? Maybe even smooth horizontal motion?

I changed cube to tile since the former suggests 3D :grin:

The sketch below is very basic but demonstrates a simple Tile class that could easy be extended and modified to suit your sketch.

In the sketch a random tile is created and ‘falls’ down the screen. The ‘a’ and ‘d’ keys will move the tile left and right respectively. When the tile disappears a new tile is created.

String letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int tileSize = 30, nbrRows = 20, nbrCols = 16, cTime;
Tile tile;

void settings() {
  size(tileSize * nbrCols, tileSize *nbrRows);
}

void setup() {
  tile = getTile();
  cTime = millis();
}

void draw() {
  int eTime = millis() - cTime;
  cTime = millis();
  background(200, 200, 255);
  stroke(0, 48);
  for (int i = tileSize; i < width; i+= tileSize)
    line(i, 0, i, height);
  tile.update(eTime);
  tile.render();
  if (tile.pY > height)
    tile = getTile();
}

void keyTyped() {
  switch(key) {
  case 'a':
    tile.moveLeft();
    break;
  case'd':
    tile.moveRight();
    break;
  }
}

Tile getTile() {
  int pn = floor(random(26));
  String ch = letters.substring(pn, pn+1);
  int col = floor(random(nbrCols));
  return new Tile(ch, 0.045, col);
}


class Tile {
  String letter;
  float pX, pY;
  int col; // Board col start / target
  float speed;
  int status;

  public Tile(String letter, float speed, int column) {
    this.letter = letter;
    this.speed = speed;
    col = column;  // Start column
    pX = this.col * tileSize;
    pY  = -tileSize; // Start off screen
  }

  public void render() {
    push();
    translate(pX, pY);
    stroke(255, 255, 0);
    strokeWeight(2);
    fill(0, 0, 128);
    rect(0, 0, tileSize, tileSize);
    textSize(tileSize);
    textAlign(CENTER, CENTER);
    fill(255, 255, 0);
    noStroke();
    text(letter, 0, 0, tileSize, tileSize);
    pop();
  }

  public void update(int etime) {
    float dy = speed * etime;
    pY += dy;
    int targetX = col * tileSize;
    if (abs(pX - targetX) >= 1) {
      float dx = 2.5 * speed * etime;
      pX += (pX > targetX) ? -dx:dx;
    } else {
      pX= targetX;
    }
  }

  public void moveLeft() {
    if (col > 0)  col --;
  }

  public void moveRight() {
    if (col < nbrCols - 1) col++;
  }
}

Thank you once more for your valuable advice. I have now redesigned my game utilizing classes and objects.

Currently, my game features:

  • A Tile class for a single Spanish letter tile, incorporating smooth pixel-level falling and horizontal movement.
  • A Board class that maintains landed tiles within a 2D grid.
  • Horizontal and vertical searches for the current Spanish word after each tile lands.
  • Weighted generation of Spanish letters, ensuring more frequent occurrence of common letters.
  • Particle explosion effects and a sound effect upon finding a correct word.
  • A player, two AI allies, scoring, a right-side team panel, and states for menu, instructions, and game over.

I am seeking guidance on ensuring the game remains stable when issues arise. For instance:

  1. What game states should be verified before updating or drawing a tile?
  2. What are effective strategies for managing situations such as a full board, absence of active tiles, invalid landing positions, missing sound or font files, or an unavailable audio device?
  3. How should I design an error or game-over screen to ensure players receive a friendly message instead of a traceback or stack dump?
  4. During development, should I log unexpected exceptions while keeping technical details hidden from the player?

My objective is to safely handle foreseeable issues, allow the game to return to a valid state or menu, and ensure players never encounter technical error messages.

It seems that you’re game is much further on that I realised.

In my first post I suggested creating ‘modes’ you can extend this to include

LOADING - loading resources e.g. fonts, audio, graphics etc. and initialising any devices e.g. audio, camera etc. In most cases any error here will be unrecoverable. If an unrecoverable error occurs change the mode to CRASH mode -
CRASH - in this mode give a non-technical description of the problem e.g. can’t find audio files suggest fixes e.g. ensure the files are in the correct folder and offer a way for the user to exit and close the sketch.

As the number of modes increase, managing mode changes and user input can require complex if and switch statements which is a common cause of logical errors that are difficult to trace and correct.

Object orientation again comes to the rescue. In the demo sketch below there are just 3 modes for

  1. loading resources
  2. start menu
  3. playing the game

Each mode has its own class that inherits from a abstract base class that provides default behaviour and a single instance of each is instantiated in setup.

There are two core methods used when changing modes -

  1. enter() which initialises any variables / state needed for the mode to execute
  2. leave() which cleans up variables / state when the mode is finished with

other methods are provided to create the mode display and handle common user interaction.

Note that all mode changes are performed with the setState method to ensure clean entry to and exit from the current mode.

Although there is a lot of code you will find just one if statement to handle mode changes

Mode loadResources, startMenu, playGame;
Mode prevMode, currMode;

public void setup() {
  size(640, 480);
  surface.setTitle("Welcome to my game");
  surface.setResizable(true);
  // Create the scenes
  loadResources = new LoadingMode();
  startMenu = new MenuMode();
  playGame = new GamePlayMode();
  
  // MUST set the current mode to a valid mode and enter it
  prevMode = null;
  currMode = loadResources;  // currMode must never be null
  currMode.enter();          // prepare / init mode
}

// Change the current mode. This method ensures that currMode is never null
// Returns true if the mode has been changed else false
public boolean setMode(Mode mode){
  if(mode != null && mode != currMode){
    currMode.leave();
    prevMode = currMode;
    currMode = mode;
    currMode.enter();
    return true;
  }
  return false;
}

/*
These standard Processing methods simply forward actions and events to the current
mode if it exists. If you add other event handlers then make sure you updtae the
class Mode with a matching empty
*/
public void draw() { 
  currMode.draw();
}

public void mouseMoved() { currMode.mouseMoved(); }
public void mouseClicked() { currMode.mouseClicked(); }
public void mousePressed() { currMode.mousePressed(); }
public void mouseReleased() { currMode.mouseReleased(); }
public void mouseDragged() { currMode.mouseDragged(); }

public void keyPressed(){ currMode.keyPressed(); }
public void keyReleased(){ currMode.keyReleased(); }
public void keyTyped(){ currMode.keyTyped(); }

/*
  This is the base class for all modes and simply provides empty functions 
  and event handlers for modes that do not need them.
*/
abstract class Mode {
  protected String type = "";

  public Mode(String type){ this.type = type;} 
  public void enter() { }  // initialise any data for this mode
  public void leave() { }   // cleanup code when we leave this mode

  public void draw() { }
  public void mouseMoved() { }
  public void mouseClicked() { }
  public void mousePressed() { }
  public void mouseReleased() { }
  public void mouseDragged() { }

  public void keyPressed(){ }
  public void keyReleased(){ }
  public void keyTyped(){ }
}


class LoadingMode extends Mode{
  
  public LoadingMode(){
    super("LOADING");
  }
  
  public void enter() {
    surface.setTitle(type); // for demo purposes only
    println("ENTER MODE : " + type );
  }
  
  public void draw(){
    background(255,255,200);
    fill(0,0,200);
    textAlign(CENTER, CENTER);
    textSize(40);
    text(type, 0, 0, width, height);
    textSize(24);
    text("Click for game start menu", 0, height - 40, width, 40);
  }
  
  public void mouseClicked(){
    setMode(startMenu);
  }
  
  public void leave() {
    println("LEAVE MODE : " + type );
  }
}


class MenuMode extends Mode{
  
  public MenuMode(){
    super("START MENU");
  }
  
  public void enter() {
    surface.setTitle(type); // for demo purposes only
    println("ENTER MODE : " + type );
  }
  
  public void draw(){
    background(0,0,128);
    fill(255);
    textAlign(CENTER, CENTER);
    textSize(40);
    text(type, 0, 10, width, height - 60);
    textAlign(CENTER, CENTER);
    textSize(24);
    text("Click to start playing", 0, height - 40, width, 40);
  }
  
  public void mouseClicked(){
    setMode(playGame);
  }
  
  public void leave() {
    println("LEAVE MODE : " + type );
  }
}


class GamePlayMode extends Mode{
  
  public GamePlayMode(){
    super("PLAYING");
  }
  
  public void enter() {
    surface.setTitle(type); // for demo purposes only
    println("ENTER MODE : " + type );
  }
  
  public void draw(){
    background(0,255,0);
    fill(200, 0, 0);
    textAlign(CENTER, TOP);
    textSize(60);
    text(type, 30, 10, width-60, height-60);
    textAlign(CENTER, CENTER);
    textSize(24);
    text("Click to return to previous mode", 0, height-40, width,40);
  }
  
  public void mouseClicked(){
    setMode(prevMode);
  }
    
  public void leave() {
    println("LEAVE MODE : " + type );
  }
}

Thanks again for your help with the design. I’ve been using your tips on using separate tabs, the Tile and Board classes, making things move smoothly, and using mode and state objects. It’s been really helpful. So, my game is all about falling letters in real time. You control one tile as it falls, moving it left or right, and then drop it onto a 2D board. As the tiles land, they stack up. The board is always checking for specific words in the rows and columns. When it finds one, the tiles that make up that word explode, the board collapses, and you get points. It’s a pretty simple idea, but it can get really challenging. The goal is to keep finding words and clearing the board to rack up as many points as possible. I’ve also got some other features like weighted letter frequency, cool particle effects, sound effects, allies that use AI, screens that show my score and level, and a system that handles loading and crashing. I’m interested in learning about creating engaging gameplay mechanics that players can interact with. My aim is to make a game that’s fun to play over and over.

I’d like some advice on which mechanics to try out next and how to make them simple enough to test. For example:

  1. How can we make the game harder - should the tiles fall faster, start with a full board, use longer words to find, or a combination of all these things?
  2. If you score multiple words quickly, does that make the game automatically more strategic?
  3. What if we added special tiles to the game, like tiles that can be any letter, or tiles that are stuck in place, or even tiles that can damage or help your score - could that work without making things too confusing, or the code structure more complicated?
  4. When playing, how do you decide what’s best: holding onto a tile that could make a bigger word later or using a smaller word right away to free up space?

I am especially interested in advice about:

  • the purpose of a mechanic;
  • the player decision it creates;
  • what’s the smallest version I can start with first;
  • I don’t need the full code, I just want to understand how to approach the problem and then I can build a small test version on my own.
    Thank you very much again, in advance

Best Regards,

Alex

Regarding words, take a look at the source code of Lexica at GitHub - lexica/lexica: Word Game for Android - A fork of lexic (https://code.google.com/p/lexic) · GitHub . It contains word lists for many languages, and a neat word compression algorithm. It is written in java, so you can take code from it, also (I was unable to understand it, though).

It seems you are interested in Spanish word lists. Lexica contains Spanish Word lists in both accented (aábcdeé…ií…mnñoó…uúü…z) and unaccented (abcde…mnñop…z) versions. These lists are huge but you can use them to detect letter frequency.

Please note lexica includes inflected words (niño/niñas, cantar/cantaban). If you need non-inflected words only, look for some “lemario español” or dig into word puzzle games.

I have to say it is amzing how much you already achieved. Amazing!

Congratulations!

Have you considered my idea (see my image of the handwritten note) of having falling rotating Tettris Blocks with several random letters in them? That would make it fairly hard to play. You could start with

X one letter 

XX 2 letters, rotateable 

XXX 

and then 

 X 
XXX

and 

X
XXX 

XXXXX

XX
XX

 X
XXX
 X

 

where X are letters that together must be part of existing words