How can I tackle building a tetris game in C++ with my team?

  • C/C++
  • Thread starter prelic
  • Start date
  • Tags
    C++
In summary, the team is assigned to write a Tetris game in C++ and they need help. They suggest that the team makes classes to help them and then builds from there.
  • #1
prelic
14
0
I'm taking an undergrad CS course, and we've been split up into teams and have been assigned a tetris game in C++. The limitations are very loose, and we can basically do it however we want. I've had 2 C++ classes and a class in Java, so I'm not that new to programming, but I am new to something this complicated and in-depth. Most of the programs I've written have been console-based applications that are single-purpose and not very complicated. I know I won't have that much trouble writing the classes once I have a good idea of where to start and a decent algorithm, but as of now, I really have no idea where to start, so any and all advice would be greatly appreciated.
 
Technology news on Phys.org
  • #2
MVC (Model-Controller-View) You need three parts:

Model = stores the data describing the state of the program, which blocks are present, where are they?

Controller = works out how each block will move on the next go, which are already at the bottom, which are falling, where the sideways moving thing is.

View = takes the model and displays it on the screen. Don't worry about this too much - in fact for testing it might be easiest if it just wrote out lines of text with * representing the blocks.
 
Last edited:
  • #3
And the greatest part of the MVC ______ (some noun fits in that blank rather well) is that it breaks down the problem into testable units. Each part should work in somewhat of an isolation -- that is, the model doesn't care what the controller actually does so long as it actually provides the methods/functions that it's supposed to. Likewise, the controller doesn't care if the view is a GUI, text, or Morse Code. The controller only needs to know that the view will provide the necessary functions so that the controller can call them without things crashing.

To start off, get everyone together and brainstorm, map out what objects and classes and methods you'll need. It may sound a bit corny, but a 'whiteboard jam session' actually works (at least it did for me once). It's explained on this website for a class I took some time ago: http://www.cs.jhu.edu/~scott/oose/lectures/design.shtml. The idea is simply that with everyone putting up ideas together (good ideas and stupid ones too -- you need them all at first until you know where you're going with it), you'll hit on good things. And if you map them out properly (not perfect UML, but enough to make sure things work), you can see the potential problems before you start coding.

If people are hesistant, just declare that you guys should make Class X to do job Y and build from there. Once you have to start thinking of related classes and how they'll work together you'll see if class X doing job Y is really viable.
 

1. What is the purpose of doing tetris in C++?

The purpose of doing tetris in C++ is to practice programming skills and learn how to implement a popular game using a high-level programming language. It also allows for the development of problem-solving skills and understanding of data structures and algorithms.

2. Is C++ the best language for making tetris?

C++ is a suitable language for making tetris, but there are other high-level languages that can also be used effectively. The choice of language depends on the programmer's skills and preferences.

3. What are the main challenges of implementing tetris in C++?

The main challenges of implementing tetris in C++ include understanding and implementing the game mechanics, designing and managing data structures, and handling user input and game logic. Other challenges may include optimizing code for efficiency and debugging errors.

4. Are there any resources available to help with doing tetris in C++?

Yes, there are many resources available online, such as tutorials, forums, and open-source code, that can provide guidance and assistance with implementing tetris in C++. It is also helpful to refer to documentation and textbooks on C++ programming.

5. What are the benefits of doing tetris in C++ compared to other languages?

One of the main benefits of doing tetris in C++ is the control and flexibility it provides over low-level memory management, which can be useful for optimizing performance. Additionally, C++ has a large community and a wide range of libraries and tools that can aid in game development.

Similar threads

  • Programming and Computer Science
Replies
1
Views
728
  • Programming and Computer Science
Replies
8
Views
877
  • Programming and Computer Science
Replies
31
Views
2K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
3
Replies
86
Views
10K
  • Programming and Computer Science
Replies
6
Views
1K
  • Programming and Computer Science
Replies
3
Views
3K
  • Programming and Computer Science
Replies
5
Views
1K
  • Programming and Computer Science
Replies
29
Views
5K
Back
Top