C/C++ :: How To Do Basic Animation With GTK3 And Cairo Only
Apr 22, 2014
Let assume i have a gtk window with a drawing area and a button in it....
When the application is run it will show ball... when the button is pressed it will start bouncing from one side to other... When the button is pressed again it stop bouncing...
Also the window shows the current XY co-ordinates of the ball in the bottom left corner(inside the drawing area)...
I want to use C , GTK3 and CAIRO only...
I have googled and found animation example not with GTk3 but GTK's previous versions instead...those doesnt work with GTK3..i have also read cairo's official,zetecode's tutorails and some other sites..but nowhere found any solution to my problem...
I know how to do so with OpenGL and it's very easy...but i cannot apply the same logic with cairo and gtk3...please dont suggest to use GtkGlExt...i don't want to use it...
I wish to create a simple animation, similar to the pong game but completely automatic (i.e. both sides play against eachother sort of like in a screensaver of sorts).
I am clueless on to even start tackling this, what tools to use and how to use them, to make them do what I want. I have had some experience with C++ scripting while modding Fallout 3, but I'm not sure how similar the scripting system available in the SDK for that game, is to the real thing.
Like I was saying I want to create a simple animation where two AI blocks try to prevent a ball from reaching the wall behind them.
I need to run some basic statistics on about ~150 tables that are currently in dBase format. Rather than use excel to do them all individually, i was told to use s+ and write a code to loop through them, but I have never written any code and my experience with spotfire s+ is limited (the stat software i have available) ....
I am having trouble with an assignment. The assignment consists of a basic encryption and decryption program already written for me, I just have to write the encryption function. What we have to get the program to do is enter an integer and a text, and get the program to increment each letter in the text by the integer given. I did this by using a for loop and incrementing each value in the string by the integer.
However, I still can't get it to decrypt and I need the program to work with only a-z letters (if I increment each letter by 3 and I have the letter Z, it should go to Z+3 = C).
I attached the description of the attachment and below are the codes: The first file does not need to be edited.
Code: /*******************Programming Assignment 1***************/ /****************Caesar's substitution cipher**************/ /*****************YOU MUST NOT EDIT THIS FILE**************/ /****Substitute alphabets in a string using rotation key***/ /****Leave all other characters unchanged******************/ /****Confirm correct encryption by decrypting**************/
I had to learn how to use variadic templates recently, and had trouble finding simple examples that just showed the basic syntax.
So I decided to write one myself. Admittedly, it's a bit on the long side, but that is mostly because it includes five specializations.
insert Code: // Variadic.C // Compile command: g++ Variadic.C -std=c++0x // I used GCC version 4.6.3 on Ubuntu.
// This file contains a basic variadic template with five specializations. // It is intended for non-software engineers who are looking for a simple // example of variadic template syntax.
#include <stdio.h> void Swap(int *x, int *y); int *Largest(int *array, int size); int main() { int a, b, i; int c[10]; int maxaddress; }
[code]...
My swap function works fine, but I am trying to find the ADDRESS of the largest element in my array and I am getting an error using gcc on my "return &largest;" and my printf line in my main function.How can I fix this and return the address of the largest?
So I am currently in the middle of learning c++ and I decided to jump ahead of the book and tried to do add procedures. My goal is to have main calling other procedures such as welcome message().
I want to configure netbeans 7.4 settings for c++.I'm posting here because netbeans forums are close to dead. How to do the following things :-
1) When you create a new project of a 'new application' type, main.cpp is already there with some code. I want that main.cpp to be completely empty when I create a new project.
2) When you compile/build your program and run it, the output is shown in a small log window at the bottom. I want it to be shown like in a black output terminal (console ?) just like in Visual Studio or CodeBlocks. (I have some reasons for not using them instead, so don't bother about me not using them)
3) When you click the green 'Run' icon in the upper toolbar, the project is compiled/build again and then runs afterwards. I want it to just run without compiling. (Compiling/Building should be done by 'Build' icon, just like in CodeBlocks or Visual Studio)
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?
My code is rather short, but when I compile it, I get 1 error about an unresolved external symbol, it probably has something to do with the file processing. . .
Just a basic keylogger using SDL
Keylogger.h #ifndef KEYLOGGER_H #define KEYLOGGER_H #include <fstream> #include <SDL.h> using namespace std; class Keylogger{
[Code] .....
Errors
Error1error LNK2019: unresolved external symbol __imp___CrtDbgReportW referenced in function "public: char const & __thiscall std::_String_const_iterator<class std::_String_val<struct std::_Simple_types<char> > >::operator*(void)const " (??D?$_String_const_iterator@V?$_String_val@U?$_Simple_types@D@std@@@std@@@std@@QBEABDXZ)C:Usersaviedocumentsvisual studio 2013ProjectsPracticePracticeKeylogger.objPractice
How you'd type yes or no scenarios for a text based RPG? And I mean a really basic like 'you see ..... what do you do?'. Also, how would you finish a code like this.
how to put together a basic ray tracer which can model spheres and planes. I have an example ray tracer which I am currently pulling apart and sifting through line by line to try and understand exactly how it works. I have come to a point in the code which I am having trouble explaining adequately. It's a method of the Plane class, which is a class defining the planes in the scene. The method is called findIntersection and I believe its purpose is to return the distance between the origin of the ray and the point of intersection, it looks like this
The method accepts arguments of type Ray which is a class defining rays, rays are constructed from this class by supplying two vectors, a starting vector and a direction vector, the Ray class has a method function getDirection which is used in the first line of the findIntersection function which clearly just returns the direction vector. The DotProduct method being accessed belongs to the Vector class and is a standard method for finding the dot product of two vectors. "normal" is a variable of type Vector and is used in the construction of an instance of the Plane class, along with a distance from the centre of the scene and a colour. Also, in the line double b=normal.DotProduct(ray.getStart()+((normal*distance).Inverse())); the plus sign between the two vectors is an overloaded operator which adds the two vectors in the usual mathematical way, I overloaded it for neatness.
The trouble I'm having is working out what the variables a and b are doing, what they mean geometrically and how they correspond to getting the distance between ray origin and point of intersection. Clearly if the dot product of the normal with the ray equals zero then the ray is parallel to the plane and so there is no intersection but what is a's role in the return statement.
I made a basic console calculator in C++ using the Code::Blocks IDE and using the GNU GCC compiler. The problem in my code is my void function called 'operate' is getting ignored by not showing up in the console. After the first if statement I added a user input by saying Y for yes or N for no. Another if statement inside the first one shows if you type either 'Y' or 'y' it will execute the 'operate' function which will restart the calculator by having the same selection menu as in the int main function. When I call the function it does not show up in the console but just ends the program.
Here is my code:
#include <iostream> #include <cstdlib> #include <string> using namespace std; int input,input2, numAdd, numAdd2, numSub, numSub2, numMult, numMult2, numDiv, numDiv2; void operate() { cout << "Select a operator." << endl;
im trying to write a program that prompts the user to enter three numbers and then prints them vertically (each on one line), first forward and then reversed. this is how the design should look:
enter three numbers: 1 43 54
your numbers fowards:
1 43 54
your numbers backwards:
54 43 1
this is what i have thus far when it comes to code....
#include <stdio> int main (void) { // local declarations int a; int b; int c
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.
: 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.
I am trying to send yahoo mail using socket program.
Using the commands like ehlo, starttls, auth login, data,.,quit.
but starttls is error. yahoo close itself. one more thing i use this same method for gmail is working.
The problem is we must enable the ssl authentication. Like System.net mail in .net package smtp.enablessl=true. how i enable ssl authentication in starttls in c++ program