Jump to content
  • Advertisement

Archived

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

Ekim_Gram

For stuff like moving ASCII...

This topic is 5454 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
Share on other sites
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 this post


Link to post
Share on other sites
Tiffany made a very good tetris clone, Asciiris.

Last time i saw her at the Lounge.
Ask her about how to do it...

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 this post


Link to post
Share on other sites
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 this post


Link to post
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 this post


Link to post
Share on other sites
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 this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!