C/C++ :: Make Basic Snake Game Using Command Window And Screen Refreshes?
Apr 15, 2015
I am trying to make a basic Snake game using the command window and screen refreshes. So far I have a board, snake, food, and no walls. Basically I have it so the snake moves like the traditional snake in the game, when it eats the food once it grows. However when it eats the food a second time the game crashes. I think I have narrowed the issue down to the grow array that I have (below) but I am not sure if the issue could be a result of something else.
Grow Array
cord growArray (cord *p_values, int *size)
{
*size = *size + 1;
cord *p_new_values = new cord[ *size ];
[Code]....
View 7 Replies
ADVERTISEMENT
Dec 20, 2014
I wanna know how to do so a cmd window when you open a game.
Example: when I start cheese attack (just a name I like) then a cmd window come up, how do I do that?
View 1 Replies
View Related
Jun 1, 2014
I'm trying to make a simple snake game in C# using 2 Dimensional Arrays . I have a grid of labels. I am having problems with differentiating the head of the snake from the rest of it's body. Also I need generating 2 random numbers and filling them inside my array.
I don't know how to place random food on my array. This is because the food can't be placed on the location of the snake. Which brings me to my other problem which is keeping track of the snake and updating it. I don't know what structure to use and How to actually do the above methods. I've tried looking at a lot of sample snake projects but they don't have arrays in them.
View 14 Replies
View Related
Dec 29, 2012
I want to create a basic window using visual c++ 2010 express.
View 1 Replies
View Related
Dec 19, 2014
I have created an scientific calculator application and I have a VBS script that runs some of the files. I want to create a C program that runs that VBS script. however, a command window flashes before the application opens. So basically I need a short C (or C++) program that runs a VBS script without a command window popping up. I am on Windows 8 and my compiler is GCC/G++ under cygwin. Here is what I have now that DOES NOT work.
Code:
#include <windows.h>
int main()
{
ShellExecute( NULL, NULL, "StartUp.vbs", NULL, NULL, SW_HIDE);
return 0;
}
View 2 Replies
View Related
Apr 24, 2014
When things at work get overwhelming, it's not unusual for me to briefly "escape" by writing small programs simply for fun. A few days ago, I had an idea for a "binary game". I completed the first draft of it yesterday.
The idea is simple. The game uses 8-bit values. At the start of the game, a random "target" value is generated. The player is dealt a "hand" of seven values. The object is to use the values in your hand, along with some basic logical operations, to create the "target" value. While the idea is simple, the game itself can be quite difficult.
Here is an example of the output:
Code: --------------------
T: 1111 1100 (0xFC)
--------------------
0: 0000 0000 (0x00)
--------------------
1: 1100 1110 (0xCE)
2: 1010 0011 (0xA3)
3: 1100 0101 (0xC5)
4: 1011 1111 (0xBF)
5: 1010 1011 (0xAB)
6: 0001 1011 (0x1B)
7: 0001 1011 (0x1B)
--------------------
: Looking at the first column:
- 'T' is the "target" value
- '0' can be thought of as the "game board" - this is the value that needs to match the target value for a win
- '1' - '7' are the values in your "hand"
You can apply logic AND ('A'), OR ('O'), or XOR ('X') to a value in your hand with the value on the "game board". You are also allowed to apply logic to two values in your hand to create a new value for your hand. When a value from your hand is used, it is removed.
Some examples of the commands:
A30 --- apply logic AND to value #3 in your hand, and the "game board" value
O23 --- apply logic OR to value #2 in your hand and value #3 in your hand
X70 --- apply logic XOR to value #7 in your hand, and the "game board" value
You can also be dealt new values (as long as there's room in your hand) with the '+' command. 'H' or 'h' prints the help, and 'Q' or 'q' exits the game.
I haven't thoroughly tested it yet, since I just finished it a yesterday, but so far it looks good. The program itself uses only standard C.
I was dickering with the idea of supporting more logical operators (NOT, NAND, NOR, XNOR, shift), but I like the simplicity and resulting difficulty of the current implementation.
During initial testing, I realized it's possible to have doubles in your hand. Also, it's quite possible to be dealt the target value directly, which means that you could potentially win with one move, chance permitting. At first I thought about defending against these conditions, but came to the conclusion that it is fine as is - chances of an instant win are small, and if it does occur, would still be an enjoyable experience. Besides, if you're dealt the target value after the "game board" value has been modified.
Also, I did not allow a value of "zero" in the players hand. This was originally because I thought it would be of little use (though I've been reconsidering this). This also means that if two values in the hand are combined and result in zero, both values are removed and no new value is added. This was originally a bug, but I think I'll just reclassify it as a feature
So far, I found that the best strategy is to avoid modifying the "game board" value, and just play with the values in your hand. If you can get the target value in your hand, you just OR it with the "game board" and you're done.
View 2 Replies
View Related
May 26, 2013
This is the code
#include <iostream>
using std::cout;
using std::endl;
int main(int argc, char* argv[])
[Code] ...
The only Problem I have is that I need to know how to open a command window at the folder containing the .exe file(this program), inorder to enter the program name or arguments.
View 2 Replies
View Related
Oct 8, 2014
If I compile code which uses cin using the command prompt, then run the compiled program a new window opens when it reaches the cin line of code, for the input. If there is no cin used then all printing happens in the original window. Is there a way to stop this behavior of the opening of a new window?
View 1 Replies
View Related
Jan 14, 2013
this is my program, it works fine when asking for inputs, but as soon as i press enter for the output the window just dissapers.
#include<stdio.h>
main()
{int bno;
[Code].....
View 2 Replies
View Related
May 26, 2013
I have learned the basics you need to know about c++ so I was wondering, how do you make a GUI from scratch without using any programs like qt, daniweb, ect. Is there like a ongui() or something?
View 6 Replies
View Related
Sep 27, 2013
What is the command to return the position of the mouse on screen in C?
View 8 Replies
View Related
Mar 5, 2013
I am having a problem with my c++ code. I am attempting to clear the text off of the command prompt screen in a text based game program. I put a restart option using a goto in my program. How would I be able to clear all previously displayed text.
View 7 Replies
View Related
Sep 17, 2014
Basically i have a 'HomeWindow' with a button 'OptionWindow'. My idea is that the 'OptionWindow' button will open up the 'OptionWindow'. Which will give the user three options 'Option1', 'Option2' and 'Option3'. If they pick 'Option1' then in the 'HomeWindow' in a stackpanel i want it to display 'UserControl1'. Where as if they pick 'Option2' then in the 'HomeWindow' in a stackpanel i want it to display 'UserControl2'.
If you need some of my code that i have already then let me know what you need as i have a lot of it so can't paste it all in one go. But the new thing i need is the way of making the user-controls in the 'HomeWindow' change depending on what is selected in the 'OptionWindow'.
View 14 Replies
View Related
Jan 11, 2014
I am developing an app that shows a pixelated picture in a window. I am trying to capture the image, which is composed of a number of tiles processed from a mother image, but I am having difficulty since I can't reference the image on the screen. I have placed a rectangle around the image and my understanding is that I have get the window handle for the rectangle in order to save the Image as a jpg file. In the literature there is something about a Device Context and a window handle but my compiler throws out HWND and I don't really understand the device context. I am using Windows Forms, not native code.
View 6 Replies
View Related
Oct 17, 2013
So for class I have to make an array of structures for a basic contact list in a phone.
I understand the bones of the program and how to go about doing most of it but as far as arrays of structures go I am blind.
Code:
struct phone
{
char FirstName[16];
char LastName[16];
int Number[11];
};
struct phone numbers[friends]; //friends is a variable assigned by the user What I am a bit confused about is say the user enters 30 as how many friends they have. How would I assign a value to the 3rd struct for LastName?
View 3 Replies
View Related
Jan 21, 2013
How can I check if window media player is running in full screen mode & topmost in c++ MFC?
What I used is this logic:
I compared media player full screen coordinates to that of monitor coordinates.If they are same implies media player is in fullscreen.But it has one flaw.Whenever there are control(for play,pause) displayed in full screen in media player, coordinates are not coming same as that of monitor.
View 10 Replies
View Related
May 25, 2014
So I am working on making a game. The first thing I did was make a window class. This correctly makes the window and displays it.
Now, I run my game loop and it just freezes the window and shows the Application has stopped working message box. I believe this is because the Window is not actually being updated.
My game loop however, looks like this.
bool run = true;
while(run) {
Window::Render();
if (Window::IsCloseRequested())
[Code].....
View 4 Replies
View Related
May 11, 2013
I want to make a window tgat stays always on top like that of a cybercafe software. A window that cannot be closed, minimised, deactivated, etc... with wxWidgets.
So far I've tried making a frame window with the wxSTAY_ON_TOP flag. It works, but not to perfection because, when i press the windows button, the start menu interferes with the window(and taskbar too). Also, the task manager, how to deactivate it.
- a wjndow that strictly stays on top
- deactivate task manager
View 3 Replies
View Related
Oct 15, 2014
how to make a window in C++? I am trying to make a program that has a boot screen but I want it to be in its own window because it will have it's own pictures in it and text inside too. So not in a terminal but inside a external window.
View 1 Replies
View Related
May 26, 2014
I am having problems with my game of fifteen. I have implemented the swap> I know the swap takes place[using GDB] but the swap does not show on the screen even if GDB says it has taken place. I am getting no errors from the move function so I know that something is taking place. I was thinking that the problem may be in the draw function but it looks okay to me. I have looked at this over and over but I don't know why the draw is not printing the move to the screen.
#define _XOPEN_SOURCE 500
#include <cs50.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
// board's minimal dimension
#define MIN 3
// board's maximal dimension
#define MAX 9
[Code] ....
View 14 Replies
View Related
Mar 6, 2015
1. What is dll and lib?
2. How do I make dll and lib using g++ command prompt?
Also, how do I link libraries using g++?
Any good websites that covers my questions,
View 1 Replies
View Related
Apr 26, 2013
I am trying to make a program that can type a string into another window. I have gotten it to the point that it can type the string, just not correctly. It will type random numbers and not the given string. The key event uses ASCII code for the arguments, and I don't see anything wrong with my numbers. Here is the code I have so far.
#include "stdafx.h"
#include <iostream>
#include <windows.h>
[Code].....
View 2 Replies
View Related
Feb 8, 2015
Screen Splitter will allow main screen to be split into two or more sections. It will be useful for the active program's window to be resized properly to one part of the screen. Using this utility, User will be able to do a split system desktop into two or more areas....
Attached image(s)
View 2 Replies
View Related
Nov 27, 2014
I've recently refreshed my mac by reinstalling the operating system. Uploaded the previous C and C ++ source scripts I was working with but when I go to compile them through the bash terminal it says command not found? Im not sure whats going because I thought that all the gcc files were already available? What am I messing here.
View 5 Replies
View Related
Nov 22, 2013
I am looking to make a program for C++ that has a GUI other than command prompt. The program I am trying to create will ask certain questions and display the results at the end after all questions are asked and have 2 copies of the results one over the other that can be printed as a receipt. Basically I am wondering can I do this using C++. Also I want another GUI other than command prompt as well. Something close to what windows uses if possible.
View 5 Replies
View Related
Apr 2, 2013
How to make an object wrap around the screen?
View 1 Replies
View Related