For stuff like moving ASCII...

Started by
21 comments, last by Ekim_Gram 20 years, 8 months ago
quote:Original post by Ekim_Gram
*sigh* I wouldn''t have posted here if I didn''t think about it first. I spent about an hour in a doctor''s office waiting to see a surgeon thinking about it and I came up with a blank. I am programming in Windows by the way. And I''ll as the question(s) once more.

okay, usually it takes being able to try out thoughts in an actuall program.
quote:
1. Since I''m trying to make a tetris clone in ASCII and a console, how do I rotate the pieces

math. try this, on some graph paper, draw a 4x4 grid, and draw a tetris block in it. do it again with the block rotated 3 times (you should have 4 pictures. Be careful to only ROTATE, and not MIRROR the block). Take note of the coordinates of the different points on the block. maybe you will see a pattern (I know I did).
quote: move them with arrow keys (i could figure it out with letters and stuff)

GetAsyncKeyState(VK_ARROWUP); returns true if the up arrow key is currently being pressed. I bet you can figure out the names of the others. it''s in windows.h. Borland compilers have a non-standard header called conio.h that has a function called getch() that only returns if there is a character in the input buffer. Basically, it doesn''t wait around for you to hit a key. After that, it''s math. Like I said, not going to teach you how to add one to a number.
quote:and how do you have the pieces moving downward. I''m guessing it''s using sleep() or something but can somebody explain?
if you use sleep, nothing will happen while sleep is taking place. In fact nothing CAN happen. I would write a function that updates your display. then, in my main function, I would have an infinite while loop (while(1)) that I would "break" out of on a game over. in this loop, I would keep track of the time in milliseconds, using the various C/C++ standard time functions. When a certain number of milliseconds is up (remember, 1000 ms to 1 second), I call that update function I mentioned.

But that''s just me...

quote:
2. What would I need to know to do all of the things I listed above? I know a good deal of C++ as some of you now (if you didn''t, now you do) and I''m learning OpenGL but I''m not intending to use that with the game right now.

basically, mostly C with enough C++ to help model your data (though it''s really not necessary).



Do you use your powers for good or for awesome?
My newly updated site | The Cutter Project | Association of Computing Machinery

[Formerly "capn_midnight". See some of my projects. Find me on twitter tumblr G+ Github.]

Advertisement
If you know how to do a console C++ application, you should be able to write text and characters to the screen.
You cannot move characters, but you can wipe the screen and rewrite the characters.

So you need some way of knowing where every character you want to draw, has to be, and when you have drawn all the characters, you wipe the screen and redraw, make a loop.
And you could for instance make every character on the screen, have an X and Y pos, which you could change.

Also, if you know little about C++ console programming, start with that, forget about the Win32 API for now.

Search on google for "Teach yourself C++ in 21 days"
this is a great book and it''s available on the net.
Uggh, I never said that I was just starting C++. I''ve been doing it for almost a year now. God...this is so frustrating because somebody says one thing and then somebody else says another totally different thing which makes the next poster post about the right thing but they think its wrong so they repost it. I know C++ quite well but I was just asking how to get the movement down with the ASCII pieces.


There''s no town drunk here, we all take turns.
Velocity Gaming Force

This topic is closed to new replies.

Advertisement