|
Or, he typed it in lead.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
thank you for your suggestions.
Actually, I'm a beginner in Visual C++, even in C++.
so that, I need learn more.
I have searched this topic before, but most of all used for Single Document Project type.
Can you give me short explain, what do I need to reach my aim?
I means another functions except FillRect that need to draw a shape on dialog based form.
Thank you for your help and support.
|
|
|
|
|
Changing the OnButton1 handler as suggested here [^] didn't help?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
to CPallini,
Thank you once more.
Sorry if my response was late because my internet connection is slow.
Yes, I already tried your suggestion and it can fulfill my aim.
but i still confuse about some things - I have written on previous post message.
Thank you for all...
I just want to understand about FillRect and another function that I should used if I want to make my program in other ways.
I'm a beginner in C language, so that I need to learn more about it.
Thank you for your kindly support and answers...
|
|
|
|
|
First, please use code block button when posting code snippets.
As about the code, you should never call OnPaint() explicitely in your code, change from
Eka Candra wrote: void CGambarDlg::OnButton1()
{
red = green = blue = 255;
OnPaint();
}
to
void CGambarDlg::OnButton1()
{
InvalidateRect(NULL);
UpdateWindow();
}
See documentation (InvalidateRect [^], UpdateWindow [^] for details).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thank you for your advice.
I've tried. But, I still confuse about explain of InvalidateRect function.
Why this function filled with NULL value? how about value of coordinates rectangle' edges?
What is it means, this function force the program to redrawn this form dialog? In other way, it is force to run codes in OnPaint function, is it correct?
Your answer really help me, thanks a lot.
|
|
|
|
|
Consider reading the fine manual or docs from Microsoft. They havent not only written about the parameters and their usage but often some smple code to illustrate that.
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
As you may read in the documentation, InvalidateRect(NULL) call (followed by the UpdateWindow() one) make the system posting a WM_PAINT message (so that OnPaint handler is called). Using NULL as argument means 'the whole client area should be updated'. If you need to update only the rectagle area (that's good, it is better to keep the update region as small as it can be), pass a pointer to CRect having the proper dimensions.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Thanks a lot for CPallini and Superman...
Would you advice me about tutorial for GDI in Dialog Based project?
When I was searching this topic on internet, most of all are explained for Single Document Type.
It is same if I used Dialog Based and Single Document Based for a Form application?
Thank you...
|
|
|
|
|
Try here[^], and here[^], and here[^]. Lots of excellent information and tutorials to get you started.
|
|
|
|
|
Hello all
I would like to ask how to make a simple graphics for this txt based rpg I create . I was planning to make some via dark gdk . So my question would be if anyone would like to tell some basic sprite in dark gdk
below here is my game
#include<iostream>
#include<string>
#include<ctime>
#include<cstdlib>
using namespace std;
class player {
int getDamage( );
string getName( );
string getJob( );
public:
string p_name;
string p_job;
int potion;
int manaPotion;
int powerPotion;
int p_lvl;
int p_damage;
int p_magicDamage;
int p_powerDamage;
int p_life;
int p_mana;
int p_power;
int p_xp;
int p_gold;
int p_maxXp;
int p_maxLife;
int p_maxMana;
int p_maxPower;
player ( );
};
player :: player( ){
p_maxLife = 30;
p_lvl = 1;
p_maxXp = 2;
p_xp = 0;
p_gold = 10;
p_name = getName ( );
p_job = getJob ( );
p_life = p_maxLife;
p_damage = getDamage ( );
if ( p_job == "Warrior" ){
p_maxMana = 5;
p_maxPower = 10;
p_magicDamage = 5;
p_powerDamage = 10;
p_mana = p_maxMana;
p_power = p_maxPower;
}else if ( p_job == "Assasin" ){
p_maxMana = 7;
p_maxPower = 7;
p_magicDamage = 7;
p_powerDamage = 7;
p_mana = p_maxMana;
p_power = p_maxPower;
}else{
p_maxMana = 10;
p_maxPower = 5;
p_magicDamage = 10;
p_powerDamage = 5;
p_mana = p_maxMana;
p_power = p_maxPower;
}
}
string player::getName( ) {
system ( "cls" );
cout<<"\tJourney Txt Fighting Game\n\n"
<<"What is your name : ";
string name;
cin>>name;
system ( "pause" );
return name;
}
string player::getJob( ) {
int choice;
do{
system ( "cls" );
cout<<"\tJourney Txt Fighting Game\n\n"
<<"What job do you want :\n"
<<"[ 1 ] - Warrior\n"
<<"[ 2 ] - Assasin\n"
<<"[ 3 ] - Soolsa\n"
<<"Choice : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
system ( "pause" );
if ( choice == 1 ){
return "Warrior";
}else if ( choice == 2 ){
return "Assasin";
}else{
return "Soolsa";
}
}
int player::getDamage( ) {
srand ( time ( 0 ) );
int damage = rand ( ) % 5 + 1;
return damage;
}
class enemy {
int getDamage ( );
public :
enemy ( );
int e_damage;
int e_life;
int e_maxLife;
};
enemy ::enemy( ){
e_maxLife = 20;
e_life = e_maxLife;
e_damage = getDamage ( );
}
int enemy::getDamage( ) {
int damage;
if ( e_life <= 5 ) {
damage = 10;
}else {
srand ( time ( 0 ) );
damage = rand ( ) % 5 + 1;
}
return damage;
}
player hero;
enemy villain;
void menu ( );
string title ( );
void fight ( );
char switchTurn ( char turn );
int playerMove ( int &heroLife , int &heroDamage , int &enemyLife );
void run ( int &heroLife , int &enemyMaxLife );
int useItems ( int &heroLife , int &potion , int &manaPotion, int &powerPotion , int &mana , int &power );
int attack ( int &heroLife , int &mana , int &power , int &enemyLife );
int enemyMove ( int &heroLife , int enemyDamage );
void displayStatus (int &xp , int &gold , int &maxXp );
void displayHp( );
void shop ( int &gold , int &potion , int &manaPotion , int &powerPotion);
void check ( int &xp , int &maxXp , int &life , int &maxLife , int &mana , int &maxMana , int &power , int &maxPower );
int main ( ) {
menu ( );
cin.ignore ( cin.rdbuf ( ) ->in_avail ( ) + 1 );
return 0;
}
inline string title ( ){
return "\tJourney Txt Fighting Game\n\n";
}
void menu ( ){
int choice;
do {
system ( "cls" );
cout<<title ( )
<<"What do you want to do ? \n"
<<"[ 1 ] - fight an enemy\n"
<<"[ 2 ] - goto a shop\n"
<<"[ 3 ] - display character status\n"
<<"[ 4 ] - exit the game\n"
<<"Choice : ";
cin>>choice;
} while ( choice < 1 || choice > 4 );
switch ( choice ){
case 1 :
cout<<"Your are about to fight now an enemy \n";
system ( "pause" );
fight ( );
break;
case 2 :
cout<<"You are about to go in to a shop now\n";
system ( "pause" );
shop ( hero.p_gold , hero.potion , hero.manaPotion , hero.powerPotion );
break;
case 3 :
cout<<"Character info now loading.....\n";
system ( "pause" );
displayStatus ( hero.p_xp , hero.p_gold , hero.p_maxXp );
break;
case 4:
cout<<"Thanks for playing .......\n";
break;
}
}
void fight ( ){
char playerTurn = 'x';
char enemyTurn = 'o';
char turn = playerTurn;
int life;
int faint = 0;
do {
if ( turn == playerTurn ){
life = playerMove ( hero.p_life , hero.p_damage , villain.e_life );
turn = switchTurn ( turn );
}else {
life = enemyMove ( hero.p_life , villain.e_damage );
turn = switchTurn ( turn );
}
}while ( life > faint );
system ( "cls" );
cout<<title ( );
if ( hero.p_life <= 0 ){
cout<<"GAME OVER YOU HAVE BEEN DEFEATED.....\n"
<<"To play again please restart the game....\n";
system ( "pause" );
}else{
cout<<"CONGRATULATION YOU DEFEAT THE ENEMY......\n"
<<"you have loot 1 gold .\n";
check ( hero.p_xp , hero.p_maxXp , hero.p_life , hero.p_maxLife , hero.p_mana , hero.p_maxMana , hero.p_power , hero.p_maxPower );
villain.e_life = villain.e_maxLife ;
hero.p_gold = hero.p_gold + 1;
system ( "pause" );
menu ( );
}
}
char switchTurn ( char turn ) {
if ( turn == 'x')
return 'o';
else
return 'x';
}
int playerMove ( int &heroLife , int &heroDamage , int &enemyLife ) {
int move;
int life;
do{
system ( "cls" );
displayHp ( );
cout<<"What is your move ?\n"
<<"[ 1 ] - attack the enemy\n"
<<"[ 2 ] - use items\n"
<<"[ 3 ] - run \n"
<<"Choice : ";
cin>>move;
} while ( move < 1 || move > 3 );
switch ( move ) {
case 1 :
life = attack ( hero.p_life , hero.p_mana , hero.p_power , villain.e_life );
return life;
break;
case 2 :
life = useItems ( hero.p_life , hero.potion , hero.manaPotion , hero.powerPotion , hero.p_mana , hero.p_power );
return life;
break;
case 3 :
run ( hero.p_life , villain.e_maxLife );
return life;
break;
}
}
void run ( int &heroLife , int &enemyMaxLife) {
displayHp ( );
cout<<"Escaped safely ....\n";
hero.p_life = heroLife;
villain.e_life = enemyMaxLife;
menu ( );
}
int useItems ( int &heroLife , int &potion , int &manaPotion , int & powerPotion , int &mana , int &power ){
int choice;
do{
system ( "cls" );
cout<<title ( )
<<"Inventory : \n"
<<"[ 1 ] - potion "<<potion<<" pcs\n"
<<"[ 2 ] - mana potion "<<manaPotion<<" pcs\n"
<<"[ 3 ] - power potion "<<powerPotion<<" pcs\n"
<<"What do you want to use : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
switch ( choice ) {
case 1 :
if ( potion <= 0 ){
cout<<"Sorry out of stock\n";
system ( "pause" );
return heroLife;
}else{
cout<<"You have use a potion\n";
system ( "pause" );
heroLife = heroLife + 10;
potion--;
if ( heroLife > hero.p_maxLife ){
heroLife = hero.p_maxLife ;
return heroLife;
}else{
return heroLife;
}
}
break;
case 2:
if ( manaPotion <= 0 ){
cout<<"Sorry out of stock\n";
system ( "pause" );
return heroLife;
}else{
cout<<"You have use a mana potion\n";
system ( "pause" );
mana = mana + 10;
manaPotion--;
if (mana >hero.p_maxMana ){
mana = hero.p_maxMana ;
return heroLife;
}else{
return heroLife;
}
}
break;
case 3:
if ( powerPotion <= 0 ){
cout<<"Sorry out of stock\n";
system ( "pause" );
return heroLife;
}else{
cout<<"You have use a power potion\n";
system ( "pause" );
power = power + 10;
powerPotion--;
if (power > hero.p_maxPower ){
power = hero.p_maxPower ;
return heroLife;
}else{
return heroLife;
}
}
break;
}
}
int attack ( int & heroLife , int &mana , int &power , int &enemyLife ){
int choice;
do{
system ( "cls" );
cout<<title ( )
<<"what do you want to use ?\n"
<<"[ 1 ] - normal attack\n"
<<"[ 2 ] - magic attack\n"
<<"[ 3 ] - power attack\n"
<<"choice : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
switch ( choice ) {
case 1 :
cout<<"You have inflicted a normal damage of "<<hero.p_damage <<" to your enemy\n";
system ( "pause" );
enemyLife = enemyLife - hero.p_damage ;
return enemyLife;
break;
case 2 :
if ( mana <= 0 ){
cout<<"Sorry out of mana\n";
system ( "pause" );
return enemyLife;
}else {
cout<<"You have inflicted a magic damage of "<<hero.p_magicDamage <<" to your enemy\n";
system ( "pause" );
mana = mana - 1;
enemyLife = enemyLife - hero.p_magicDamage ;
return enemyLife;
}
break;
case 3:
if ( power <= 0 ){
cout<<"Sorry out of power\n";
system ( "pause" );
return enemyLife;
}else {
cout<<"You have inflicted a power damage of "<<hero.p_powerDamage <<" to your enemy\n";
system ( "pause" );
enemyLife = enemyLife - hero.p_powerDamage ;
power = power - 1;
return enemyLife;
}
break;
}
return enemyLife;
}
int enemyMove ( int &heroLife , int enemyDamage ){
system ( "cls" );
displayHp ( );
cout<<"The enemy inflicted damage of "<<enemyDamage<<" to your life.\n";
heroLife = heroLife - enemyDamage;
system ( "pause" );
return heroLife;
}
void displayStatus ( int &xp , int &gold , int & maxXp ){
system ( "cls" );
cout<<title ( )
<<"Player Status \n"
<<"Player Name : "<<hero.p_name <<endl
<<"Player Job : "<<hero.p_job <<endl
<<"Player lvl : "<<hero.p_lvl <<endl
<<"HP : "<<hero.p_life <<endl
<<"MANA : "<<hero.p_mana <<endl
<<"POWER : "<<hero.p_power <<endl
<<"\ncurrent Gold : "<<gold <<endl
<<"Exp : "<<xp <<endl
<<"Exp to lvl up : "<<maxXp <<endl;
system ( "pause" );
menu ( );
}
void displayHp ( ) {
system ( "cls" );
cout<<title ( )
<<"Player \n"
<<"HP : "<<hero.p_life <<endl
<<"MANA : "<<hero.p_mana <<endl
<<"POWER : "<<hero.p_power <<endl<<endl
<<"Enemy \n"
<<"HP : "<<villain.e_life <<endl<<endl<<endl;
}
void shop ( int &gold , int &potion , int &manaPotion , int &powerPotion ){
system ( "cls" );
int choice;
do {
cout<<title ( )
<<"Current gold : "<<gold<<endl
<<"what do you want to buy ?\n"
<<"[ 1 ] - <potion> restores 10 hp cost 5 gold\n"
<<"[ 2 ] - <mana potion> restores 2 mana cost 5 gold \n"
<<"[ 3 ] - <power potion> restores 2 power cost 5 gold\n"
<<"choice : ";
cin>>choice;
} while ( choice < 1 || choice > 3 );
switch ( choice ) {
case 1 :
if ( gold > 0 ){
cout<<"You have buy a potion.\n"
<<"Thanks for buying.\n";
system ( "pause" );
potion++;
gold = gold - 5;
}else{
cout<<"Insufficient gold.\n";
system ( "pause" );
}
break;
case 2 :
if ( gold > 0 ){
cout<<"You have buy a mana potion.\n"
<<"Thanks for buying.\n";
system ( "pause" );
gold = gold - 5;
manaPotion++;
}else{
cout<<"Insufficient gold.\n";
system ( "pause" );
}
break;
case 3:
if ( gold > 0 ){
cout<<"You have buy a power potion.\n"
<<"Thanks for buying.\n";
system ( "pause" );
gold = gold - 5;
powerPotion++;
}else{
cout<<"Insufficient gold.\n";
system ( "pause" );
}
break;
}
menu ( );
}
void check ( int &xp , int &maxXp , int &life , int &maxLife , int &mana , int &maxMana , int &power , int &maxPower ){
if ( xp >= maxXp ){
system ( "cls" );
cout<<"CONGRATULATION YOU HAVE LVL UP .....\n";
life = life + 1;
maxLife = maxLife + 1 ;
mana = mana + 1;
maxMana = maxMana + 1;
power = power + 1;
maxPower = maxPower + 1 ;
maxXp = maxXp + 2;
}else
xp = xp + 1;
}
Any comments or suggestion to make this game better is kindly appreciated
|
|
|
|
|
I suppose the Collaboration / Testing forum [^] is more appropriate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
sorry to ask but is it in here also?
|
|
|
|
|
Yes, there's the link to, in my previous answer.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Sorry sir but I am a little confuse ^_^
I am still newbie here in codeproject so I thought its better
to ask a little ^_^
|
|
|
|
|
Click here to gain access to the collaboration / testing forum.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hello sir now I post again the game code in the section what you have said ^_^
By the way sir where can i find here some tutorials about the basic of 2d sprite using dark gdk kit for c++
thanks again
|
|
|
|
|
HI all,
I m using System Tray Icon for my application.
i m taking help of this article for system tray icon.
Adding Icons to the System Tray[^]
I m already ask this query to author of article but he not respond me.
please help me for this.
this application works fine on VISTA,but when i run application on XP,its create system tray icon but bot display the ballon.
please help me....
Please provide me any demo application for this
thanks in advance.
To accomplish great things, we must not only act, but also dream;
not only plan, but also believe.
modified on Thursday, September 24, 2009 7:16 AM
|
|
|
|
|
See MSDN official sample for System tray (in SDK)
|
|
|
|
|
I am useing VC++ 2008 Service Pack2 OS Microsoft Windows XP.I had create simple Dialog Based application and add a button and Edit box.On Button Click open a folder dialog Box.When i click on Button and select a file name and again click on button then i am getting exception.
Unhandled exception at 0x7ca51646 in test.exe: 0xC0000005: Access violation reading location 0x01064db0.
I debug the code and found when cursor come here then exception
if (dlg.DoModal()==IDOK)
code of ButtonClick
const char szFilters[]="Excel Files|*.xls;*.xlsx|";
CKSFileDialog dlg (TRUE, "xlsx", NULL,OFN_FILEMUSTEXIST| OFN_HIDEREADONLY, szFilters,this);
dlg.SetMyParent(this);
if (dlg.DoModal()==IDOK)
{
SetDlgItemText(IDC_EDIT1, dlg.GetPathName());
}
Plz help me
|
|
|
|
|
The end of the filter must have 2 pipe symbols.
const char szFilters[]="Excel Files|*.xls;*.xlsx||";
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
thank for reply but still problem is same.
|
|
|
|
|
Please try without the SetMyParent call.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
i try this but still problem is same.
|
|
|
|
|
Did you override DoModal in your class?
If so, what changes has been done in it.
Generally, what was the reason to derive your own class from CFileDialog ?
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|