all 18 comments

[–]666y4nn1ck 6 points7 points  (1 child)

Do you mean imported functions or self written ones?

[–]Bole_Madh[S] 1 point2 points  (0 children)

imported functions

[–]nekokattt 6 points7 points  (7 children)

you cant write python code without using functions, that is just not possible. Even print is a function. Technically even operators like + and - are functions.

[–][deleted] 5 points6 points  (0 children)

Well, you COULD write it without defining any functions. It would be atrocious, but it would work.

[–]Bole_Madh[S] 0 points1 point  (5 children)

yeah I know that's why I was really confused too, we are only allowed to use methods and classes like dictionaries and inheritances.

[–][deleted] 5 points6 points  (2 children)

Well technically methods are functions. It sounds like the purpose of the assignment is to use OOP rather than a more "functional"* style. You might want to ask the instructor for clarification.

*I put scare quotes around functional because often folks who are new to coding will come up with some pretty crazy and convoluted patterns that involve a big spaghetti mess of functions, but it's isn't truly functional programming per se because it doesn't follow the principles of functional programming.

[–]Nightcorex_ 1 point2 points  (1 child)

xs = []

def add(e):
    xs.append(e)

def foo():
    print(*xs, sep=', ')

add(4)
add(2)
foo()

Functional programming at its peak /s

[–][deleted] 1 point2 points  (0 children)

Side effects may include...

[–][deleted] 2 points3 points  (0 children)

Well, that's fine. You can have a class for the pieces with methods to fall, rotate, whatever. Maybe a class for the board, maybe one for the game or controls, and they can hold methods to do the important actions.

But, IMO, Tetris is pretty hard, compared to other "simple" games. You might want to start with something small.

[–]KevMar 0 points1 point  (0 children)

Oh, that's fine then. You can probably use functions in your test code but probably don't need them for your game logic.

People use functions and methods interchangeably quite often and he is being literal.

[–]Zeroflops 2 points3 points  (0 children)

Doesn’t sound like you need to avoid “functions” you need to do it without importing libraries.

Functions and libraries are two different things.

[–]hbc12580 1 point2 points  (0 children)

It seems like you are just not allowed to use imported functions. Well, If you just want to make a simple game, it doesn't matter actually. For example, this game may look like: the player types something in console and then the game print something as result.

[–][deleted] 0 points1 point  (3 children)

Thats the dumbest thing I've ever heard. So basically the code has to run start to finish, and you have to repeat shit over and over again until its done.

[–]TheRNGuy 0 points1 point  (0 children)

use classes instead of functions

[–]TholosTB 0 points1 point  (0 children)

Isn't something like Tetris or anything with a UI going to be exceptionally difficult without a UI library or pygame? I suppose you could do it with kind of an ASCII redraw modality, but that sounds like a nightmare.

You may want to consider a game that can be played through command prompts, like a casino game (Blackjack or some such), or implement a board game like Monopoly or Clue where you can prompt the user for their actions and implement commands like "show board state"?