• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# For stuff like moving ASCII...

## Recommended Posts

Ekim_Gram    418
Would you have to use console functions for it? Like, say your making a tetris, if you hit the right arrow key, the piece moves to the right one space. Is that it? Or can somebody explain to me if I''m wrong?
There''s no town drunk here, we all take turns. Velocity Gaming Force

##### Share on other sites
Ekim_Gram    418
Man, you sure love to make things hard for me doncha midnight? Anyway, I''ll post another question. How can you make just tetris in a console without grphics and not knowing object collision and such? GameDev here says it''s quite easy to though. How can you get the blocks and stuff to move downward and how can you use input from the keyboard using the arrows to make the blocks move left and right?

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

##### Share on other sites
pimple    122
wait, let me see if i got your second question right...

"How do I make a game not knowing how to make games?"

o_O

##### Share on other sites
Nik02    4348
Tiffany made a very good tetris clone, Asciiris.

Last time i saw her at the Lounge.

Some tips:

Making blocks 'fall' down:

blockY++;

Getting input generally:

key = getch();

-or-

GetAsyncKeyState();

You generally can't make a tetris clone without a simple collision detection logic. BUT, it really can be very simple !

[edited by - Nik02 on August 12, 2003 2:22:26 PM]

##### Share on other sites
Typhoon    122
www.gametutorials.com has tutorials for the thing I think your looking for. Just go to the language your using in the tutorials section and there''s a few tutorials on things used to make a console game like how to make something move.

##### Share on other sites
Thank you Nik02 for the compliment on AsciiRis.

quote:
Original post by Ekim_Gram
Man, you sure love to make things hard for me doncha midnight? Anyway, I'll post another question. How can you make just tetris in a console without grphics and not knowing object collision and such? GameDev here says it's quite easy to though. How can you get the blocks and stuff to move downward and how can you use input from the keyboard using the arrows to make the blocks move left and right?

Hey there,
As you probably know AsciiRis uses the win32api, it uses WriteFile() to draw to the screen and getch() to get user input, in the UserInput() function, AsciiRis has the following code to find which key is being pressed by using the keycodes, it then assigns the variables to the keycodes, (so we know that when bLeft is true that the left arrow key is being pressed) ...

		else if(key == 224)		// it's a cursor key		{			switch(_getch())			{				case 75:					bLeft = true;					//left					break;				case 77:					bRight = true;					//right					break;				case 72:					bRotCounterClock = true;					//up					break;				case 80:					bRotClock = true;					//down					break;			}		} Knowing which key is being pressed is the first step, AsciiRis then uses the following code in the ProcessPiece() function to determine what to do when that key is being pressed ...   	/*here is where we say, if the left key is down move the piece to the left*/	else if (bLeft)	{						/*pieceX is the horizontal axis, decrementing pieceX with the -- symbol we are telling the cursor to go left (or maybe you prefer to think of it as going backwards, like the backspace key)*/		pieceX--;					bLeft = false;		/*we set bleft to false again to prevent the piece from continuing to move left when we let go of the left arrow key*/	}	else if (bRight)		/*if the right key is pressed*/	{		pieceX++;		/*this instance of pieceX is being incremented, thus telling the cursor to move right (or forward, however you like to think of it) */		bRight = false;		/*set it to false again so that we know when the key isnt being held down any longer*/	}

If you have any more questions i dont mind trying to answer them for you.
Good luck and i hope that helps!

An ASCII tetris clone... | AsciiRis

[edited by - Tiffany Smith on August 13, 2003 3:30:15 PM]

##### Share on other sites
capn_midnight    1707
quote:
Original post by Ekim_Gram
Man, you sure love to make things hard for me doncha midnight? Anyway, I''ll post another question. How can you make just tetris in a console without grphics and not knowing object collision and such? GameDev here says it''s quite easy to though. How can you get the blocks and stuff to move downward and how can you use input from the keyboard using the arrows to make the blocks move left and right?

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

I''m making things hard for YOU???? I do believe it''s the other way around. Your questions are almost completely nonsense.

"Would you have to use console functions for it?"
I don''t know, are you developing it for windows console (which you are most likely doing)? You could also be trying to emulate ASCII in a Win32 GDI, OGL, or DX. Hell, I don''t even know if you are doing this on WINDOWS, you could be doing it on Linux for all I know.

"Like, say your making a tetris, if you hit the right arrow key, the piece moves to the right one space. Is that it?"
Like, totally, is what it? You have just describe how the game plays, which is in no way how the game is coded. You need to know how to find out if the player has hit the arrow key, then you need to know how to change the location of the block after that. The first one requires a function call, but the second one is simple arithmetic, and we are certainly NOT going to teach you addition and subtraction.

"Or can somebody explain to me if I''m wrong?"
The question is, what could you be wrong about? You haven''t provided enough information for us to know what you are doing. Sure, we know you are making a tetris game, and we know you are perplexed on how to get the pieces to move in responce to input, but that''s it! We need more info! What OS are your using? What language? What compiler? What API? How is your data modelled? How much time have you spent trying to find these answers on your own?

There are so many different ways to do things with computers, that we require you to post extra information before anyone can possibly give you an answer without making assumptions.

Maybe the Beginner''s forum needs a new post form, one that includes sections for all pertinent information to the question. Of course, who''s to say it would actually be used.

I know I was new at one point, but I didn''t go around asking people "How do I make my tetris block move." Maybe I''m a little more intelligent than most people and could figure out for myself, "Well, I need to have some way to store the current location of the block. AHA! I''ll use an int for it''s X coord and an int for it''s Y coord. Now, I need some way to change that when I have recieved input. AHA! I''ll use increment and decrement operators. So, if the block is going down, along the Y axis, down is the positive direction on the computer screen, so that means I must INCREMENT the Y coord to move the block down. Conversly, I must DECREMENT the Y coord to move the block UP. What about X? Well, the X axis runs positive to the right, so, incrementing will move the block to the right, and decrementing to the left. WOW! That wasn''t hard! But how do I know when a key is pressed? When I first started, I read a C book, I must have seen something in there. Let me think...oh yeah! I remember now, it was getchar(). Let''s see if that works...nope, it didn''t. Now what...let''s search my help files! Hmmm...I''m using Borland...conio.h...getch()...hmm, does that work? Well, it sort of does, but any time I hit an arrow key, I get two numbers? Now what am I going to do? I know, since I''m reading in characters, and getting two character, what is multiple characters in a sequence called? A string! I''ll treat input as string input instead of single character input, and if I get a certain two letter string, than that must be the RIGHT arrow! Or, I could just use the numpad, the I can use 8, 4, 6, 2, and still have only character input! Okay, now how do I...."

Of course, with the speeds that my mind operates at, this thought process is much faster than the time it takes to read it.

This wasn''t some magical process. This didn''t take years of programming knowledge to figure out. This took common sense, the ability to think, and the ability to use the referrences I had on hand.

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

##### Share on other sites
CodeMunkie    805
*wipes tear from eye* That was beautiful man.

##### Share on other sites
I had no trouble determining what he was saying at all.
Btw: capn_midnight - how long did it take you to type all that?

An ASCII tetris clone... | AsciiRis

##### Share on other sites
Guest Anonymous Poster
You are soooooo arrogant capn_midnight. You''d better run a game company on your own with your common sense, the ability to think, and the ability to use the referrences I had on hand. And you are not a litlle more intelligent, but ALOT. It would be very easy for you...

##### Share on other sites
Guest Anonymous Poster
I think midnight''s being reasonable. The initial questions were quite ridiculous.

##### Share on other sites
capn_midnight    1707
quote:
Original post by Anonymous Poster
You are soooooo arrogant capn_midnight. You''d better run a game company on your own with your common sense, the ability to think, and the ability to use the referrences I had on hand. And you are not a litlle more intelligent, but ALOT. It would be very easy for you...

go ahead, hide behind the AP cloak...

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

##### Share on other sites
quote:
Original post by Anonymous Poster
I think midnight's being reasonable. The initial questions were quite ridiculous.

No they weren't, what are you smoking? ...

Here ill even break it down for you ...

(title)
- "For stuff like moving ASCII..."

Ok so i get from this title, that he wants to move some kind of ASCII character.

(the original post)
- "Would you have to use console functions for it?"

I get from this that he is wondering if one needs to use an api of some kind.

- "Like, say your making a tetris,"

Ok assume we are making a Tetris game

- "if you hit the right arrow key, the piece moves to the right one space."

He is asking if the piece moves to the right one space at a time when you hit the right arrow key.

- "Is that it? Or can somebody explain to me if I'm wrong?"

He is asking if he is right in assuming that the piece moves one space at a time.

Give him a break!.

An ASCII tetris clone... | AsciiRis

[edited by - Tiffany Smith on August 13, 2003 12:50:16 PM]

##### Share on other sites
capn_midnight    1707
quote:
Original post by Tiffany Smith
- "if you hit the right arrow key, the piece moves to the right one space."

He is asking if the piece moves to the right one space at a time when you hit the right arrow key.

- "Is that it? Or can somebody explain to me if I'm wrong?"

He is asking if he is right in assuming that the piece moves one space at a time.

Give him a break!.

He gave a description of the effect he wants, and then asks if that is right. I don't know! How does he want the game to go? If he wants it to be pure Tetris, then yes, that's how the game goes, but shouldn't he know that already? I mean, I could imagine that someone could somehow possibly avoided Tetris all their lives, and heard someone tell them they need to make a Tetris game. If that were me, once I decided I would make the game, I would use the resources I have on hand and find a complete Tetris game somewhere on the 'net so that I could analyze it. Not knowing what the game was, I would play the game, and learn what the elements are. For a game like tetris, you should be able to figure it out in about 15 minutes.

The thing that conscerns me is, his post associates the ideas of "hitting a key" and "detecting it with a console function" only by proximity! For all I know, he thinks that hitting the key will somehow MAGICALLY change the location of the block.

He asks for console functions for "Moving ASCII". What exactly is "Moving ASCII"? It could be moving ASCII codes in memory. It could be ASCII animation for all I know. Then he asks if hitting the arrow keys moves the block. These could be completely seperate questions, and as we know, most n00bs are completely incapable of differentiating multiple questions from one another.

Don't give him so much credit!

 I still don't know what language or OS he is using, and unless you are psychic like I suspect, or have been communicating with him outside of the thread, you don't know either. For all we know, it could be Java (and thus, JVM, the OS is practically irrelavent), which can also do console programs, and therefore would have a completely different method of finding the input.

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

[edited by - capn_midnight on August 13, 2003 1:26:31 PM]

[edited by - capn_midnight on August 13, 2003 1:31:57 PM]

##### Share on other sites
Lektrix    106
I think that's enough now.

Ekim_Gram: As already mentioned, have a look around www.gametutorials.com, or, better yet, get a game-related book (game theory, etc.).

[ Google || Start Here || ACCU || STL || Boost || MSDN || GotW || MSVC++ Library Fixes || BarrysWorld || E-Mail Me ]

[edited by - Lektrix on August 13, 2003 1:41:49 PM]

##### Share on other sites
capn_midnight - im not trying to pick a fight with you by any means, i just feel bad for him, i assumed he is using C++ (as i have seen other posts by him saying that he knows the language), i don''t think it hurts to fill in some of the blanks using your own initiative every now and again.
personally i would hate to be confronted with such animosity if i were to post a newbie question myself.

An ASCII tetris clone... | AsciiRis

##### Share on other sites
capn_midnight    1707
I feel bad for him too, and if he is still listening, he needs to hit the books a little longer before starting a program of his own.

Otherwise, he''s just another one of the growing crowd of kids these days that either don''t care or don''t know how to express their ideas in a coherent manner. I don''t REALLY blame them, it''s the education system.

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

##### Share on other sites
Ekim_Gram    418
*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.

1. Since I''m trying to make a tetris clone in ASCII and a console, how do I rotate the pieces, move them with arrow keys (i could figure it out with letters and stuff), and how do you have the pieces moving downward. I''m guessing it''s using sleep() or something but can somebody explain?

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.

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

##### Share on other sites
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.

1. Since I''m trying to make a tetris clone in ASCII and a console, how do I rotate the pieces, move them with arrow keys (i could figure it out with letters and stuff), and how do you have the pieces moving downward. I''m guessing it''s using sleep() or something but can somebody explain?

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.

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

Feel free to play around with the code in AsciiRis, it will help you get an understanding of what you need to do.

Btw: capn_midnight is right in saying that reading up for a little longer before starting your game wouldn''t hurt.

An ASCII tetris clone... | AsciiRis

##### Share on other sites
capn_midnight    1707
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

##### Share on other sites
Snash    122
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.

Search on google for "Teach yourself C++ in 21 days"
this is a great book and it''s available on the net.

##### Share on other sites
Ekim_Gram    418
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