[QUOTE=likesoursugar;32195652]I have a question about win32(c++) You create a window.. everything is ok. But when you press the 'X' in the right upper corner and the window will close. Is there some way to prevent closing the window?[/QUOTE]
Why would you prevent the window closing? And what are you using to create the window?
[QUOTE=T3hGamerDK;32195667]Why would you prevent the window closing? And what are you using to create the window?[/QUOTE]
Because I want a window to pop up and ask the user if he really want to close the window.
CreateWindowEx();
Sounds like you're using raw Windows API, which means you've written your own event loop, right? Clicking the close button sends a [url=http://msdn.microsoft.com/en-us/library/ms632617%28v=vs.85%29.aspx]WM_CLOSE[/url] message to the window, which you can handle however you like.
[QUOTE=Wyzard;32195731]Sounds like you're using raw Windows API, which means you've written your own event loop, right? Clicking the close button sends a [url=http://msdn.microsoft.com/en-us/library/ms632617%28v=vs.85%29.aspx]WM_CLOSE[/url] message to the window, which you can handle however you like.[/QUOTE]
yes I am checking WM_CLOSE but I don't actually do anything myself if WM_CLOSE is one of the event messages. So I'm wondering why it's closing and how I can prevent it from doing so?
Are you letting the WM_CLOSE be passed to DefWindowProc()? That'll close the window automatically.
Was just going to point that out! Forgot to return 0 if the case was WM_CLOSE! thanks anyway :)
[QUOTE=Forumaster;32186956]Hopefully you guys can help me with this C++ problem I'm having. I'm trying to create an all in one utility wrapper so to speak to back up an assload of Windows 7 computers.
They want it to use WBAdmin due to the lack of having to install excess software and it creates nice VHDs.
Here's my problem: (I have full administrator rights)
I can run WBAdmin just fine from a command prompt and from a bat/cmd file. However, when I try to run it from my program, it will fail saying "File not found":
[code]
ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("cmd.exe");
backup7->Arguments = "/k C:\\Windows\\System32\\wbadmin.exe";
Process::Start(backup7);
[/code]
I've also tried:
[code]
ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("wbadmin.exe");
backup7->Arguments = "WB Args here";
Process::Start(backup7);
[/code]
Not only that, but running the batch file via this method causes it to fail: (WBLoader is in the same directory as my exe)
[code]
ProcessStartInfo^ backup7 = gcnew ProcessStartInfo("cmd.exe");
backup7->Arguments = "WBLoader.bat";
Process::Start(backup7);
[/code]
Oh, and using the Bat to EXE converter also fails. The resulting EXE also spits out a file now found error. Also I've tried putting my EXE in the System32 directory where WBAdmin is, and it STILL doesn't work.
Every other external program I've tried to run this way has worked, but not this one. Does anyone have any ideas?[/QUOTE]
Nevermind. I just made a scheduled task to run one minute from the time this program ran. Oh loopholes, how do I love thee.
[QUOTE=Wyzard;32188744]No, it's the other way around. "char const *" is a non-constant pointer to constant char; "const char *" is a synonym (and a special case of the "const" being to the left, rather than the right, of the thing it modifies). A constant pointer to non-constant char is "char * const".[/QUOTE]
Sorry, mixed them up a bit, I thought it said char * const :v:
Also, what would be the ideal STL container to store my entities in? It will be storing shared_ptrs to my base entity class. They will only store one pointer to each entity. I will be doing frequent removals and insertions, but it won't matter where because their order doesn't matter anyway.
Am I right if I think that vector actually is a good one? I could just insert elements at end, and when I want to remove an element, the std::remove should do something like inserting the backmost element there, right?
This might be a big one, I am trying to make a decoration system for the levels.
These decorations will be affected by forces such as wind and gravity however wont be physical objects.
The way I want it to work is kind of like how a plant works in real life.
The object will have an anchor point, in te image its the X named ANC.
This anchor will have a force resistance, like a spring, so when wind hits it, it will rotate to a maximum point after which it will get to the point where the force cant beat the spring force.
[img]http://i.imgur.com/RFL35.png[/img]
Anyway my question is how can I do this?
As in applying the forces, I know its trig but im not sure how.
Oh Iforgot to say I thought I could do something like use a point (V1 in the image) on each frame the V1 is moved by the forces, then I do magic trig stuff and find out how much the rotation should be, and finally reset the point.
Hey. anyone know why this class is throwing an unresolved external?
Robot.h
[code]#pragma once
#include "sprite.h"
class CGame;
class Robot :
public CSprite
{
public:
Robot(void);
Robot(float, float, float,float, float, float, int, CGame * p_Game,bool, int ,int ,int , bool );
void Update(float dt);
void RobotActionMoveForward(void);
void RobotActionMoveBackward(void);
void RobotActionTurnLeft(void);
void RobotActionTurnRight(void);
void RobotActionSpark(void);
void RobotActionStrength(void);
bool Strength;
enum Dir {N,
E,
S,
W}; //direction
Dir GetDir();//get direction
private:
Dir m_eDir;
~Robot(void);
};
[/code]
Robot.cpp
[code]
#include "stdafx.h"
#include "Robot.h"
#include "Game.h"
Robot::Robot(void)
{
}
Robot::Robot(float _x, float _y, float _w, float _h, float _vX, float _vY, int _texID, CGame * p_Game,bool _bUseSpriteSheet, int _cols,int _rows,int fps, bool _additive) : CSprite(_x, _y, _w, _h, _vX, _vY, _texID, p_Game,_bUseSpriteSheet,_cols, _rows, fps, _additive)
{
m_iType = 5; //sets the type of sprite that this object is.
m_eDir = E; // You start facing East, you can see a LANTERN, a PIECE OF ROPE.
// from here you can go North , West , South or Dennis.
}
void
Robot::Update(float dt)
{
/////////SET FRAME////////////// [b] PROBLEM SEEMS TO BE HERE [/b]
//KEY: 0=E , 1=N , 2=S , 3=W////
switch (GetDir()) {
case E:
Robot::SetAnimFrame(0);
break;
case N:
Robot::SetAnimFrame(1);
break;
case S:
Robot::SetAnimFrame(2);
break;
case W:
Robot::SetAnimFrame(3);
break;
}
/////////////////////////////////
}
void
Robot::RobotActionMoveForward(void)
{
//code to control the robot moving into the tile in front of it
//create case: direction based function with tile transition animation and array update
}
void
Robot::RobotActionMoveBackward(void)
{
//Same as above except in reverse
}
void
Robot::RobotActionTurnLeft(void)
{
//Code to control rotation of direction based on current direction
//use a case: dir response to determine new direction/animation and dir value
}
void
Robot::RobotActionTurnRight(void)
{
//Same as above but in reverse
}
void
Robot::RobotActionSpark(void)
{
//Spark in tile in front. use case: dir responce and generate spark graphic in tile
//in front and apply all setting changes in that tile based on the spark's
//presence in the tile , not here
}
void
Robot::RobotActionStrength(void)
{
//Toggle Strength
}
Robot::~Robot(void)
{
}
[/code]
my switch in robot update is throwing an unresolved external. anyone see why?
I just joined a robotics team and I'm going to have to learn to use RobotC and LabView. I have the most experience in Lua and PHP, I have done a little bit of C# and C++ but not enough. Any tips? I'm sure the existing programmers can get me up to speed but I don't know too much about their experience.
I'm working on a todo-list program, and I want to make it so when you tick a task, instead of it just popping away, I want it to fade out and then the tasks below it slowly move up. The question is, is there a formula you guys use for smooth movement?
Like when you drag a slider, and instead of it just jumping to your mouse's position, it smoothly makes it way to it, accelerating and decelerating before it's end position.
[QUOTE=Richy19;32196881]This might be a big one, I am trying to make a decoration system for the levels.
These decorations will be affected by forces such as wind and gravity however wont be physical objects.
The way I want it to work is kind of like how a plant works in real life.
The object will have an anchor point, in te image its the X named ANC.
This anchor will have a force resistance, like a spring, so when wind hits it, it will rotate to a maximum point after which it will get to the point where the force cant beat the spring force.
[img]http://i.imgur.com/RFL35.png[/img]
Anyway my question is how can I do this?
As in applying the forces, I know its trig but im not sure how.
Oh Iforgot to say I thought I could do something like use a point (V1 in the image) on each frame the V1 is moved by the forces, then I do magic trig stuff and find out how much the rotation should be, and finally reset the point.[/QUOTE]
I'm not working out a physically-correct system here, just something that should look halfway decent:
Spring torque should be -k * theta, where k is the spring constant and theta is the angular displacement from vertical. Wind can be approximated by something like w * r * cos(theta) for purely horizontal wind, where w is something like wind strength, r is the height of the object, and, again, theta is an angular displacement from vertical. Gravity would be g * m * r * sin(theta), where g is gravitational acceleration, m is mass, and r is the height of the object.
Add all these torques together and divide by moment of inertia (mass times height would be a decent approximation here). Integrate once over time to get angular velocity (each frame multiply by the delta time since the last frame, and add to a running total). Integrate again to get angle.
[editline]9th September 2011[/editline]
Actually this might be just a tad convoluted, you can probably just animate them with a fixed angular offset and a mix of sine and cosine waves (with coprime frequency values) to give them some wiggle.
[QUOTE=Richy19;32196881]This might be a big one, I am trying to make a decoration system for the levels.
These decorations will be affected by forces such as wind and gravity however wont be physical objects.
The way I want it to work is kind of like how a plant works in real life.
The object will have an anchor point, in te image its the X named ANC.
This anchor will have a force resistance, like a spring, so when wind hits it, it will rotate to a maximum point after which it will get to the point where the force cant beat the spring force.
pic
Anyway my question is how can I do this?
As in applying the forces, I know its trig but im not sure how.
Oh Iforgot to say I thought I could do something like use a point (V1 in the image) on each frame the V1 is moved by the forces, then I do magic trig stuff and find out how much the rotation should be, and finally reset the point.[/QUOTE]
The simplest solution simply be to do something like this
float angle= 0;
float angular_velocity= 0
gameloop {
float spring_acceleration= pow(angle* something+ something_else_possibly, 2)
angular_velocity+= (spring_acceleration+ world.wind_acceleration)* time
angle+= angular_velocity* time
}
I would apply gravity in similar way, but instead to the position of an object.
From how I understand your problem, I see no reason to go through the complex math you discussed in your post. What you are talking about sounds like a nightmare for no payoff.
C Noob Here:
I am trying to run my program that converts US currency into other currency (such as Yen, Euro, etc.) My program compiles after I get a warning message that says:
[code]
HW2.c: In function `main':
HW2.c:19: warning: passing arg 2 of `convert' from incompatible pointer type.
[/code]
After running it, the only values I get are 0. I have tried everything but I can not figure it out. The code is below and if someone can help me out that would be awesome.
[code]
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
double convert(int dollarinput, int * currentrates);
int main()
{
int dollarinput;
srand(time(NULL));
float currentrates[] = {1.3665 , .9970, 77.3200, 1.5868, rand() % 100};
// Exchange rates as of September 9, 2011, 12:05pm. //
printf("Enter number of dollars:\n");
scanf("%d",&dollarinput);
convert(dollarinput, currentrates);
}
double convert(int dollarinput, int * currentrates)
{
printf("You have %2.2f Euro.\n", currentrates[0] * dollarinput);
printf("You have %2.2f Canadian Dollars.\n", currentrates[1] * dollarinput);
printf("You have %2.2f Yen.\n", currentrates[2] * dollarinput);
printf("You have %2.2f Pounds(GBP).\n", currentrates[3] * dollarinput);
printf("You have %2.2f Fun Dollars.\n",currentrates[4] * dollarinput);
return 0;
}
[/code]
Here is what is looks like when it runs:
[code]
Enter number of dollars:
100
You have 0.00 Euro.
You have 0.00 Canadian Dollars.
You have 0.00 Yen.
You have 0.00 Pounds(GBP).
You have 0.00 Fun Dollars.
[/code]
This is my first time coding C since last May so I am rusty. Please be gentle :)
[QUOTE=Jookia;32192855]No it's not. It just says that the thing to the left of it (or to the right of it if it's at the start) is constant and isn't to be changed.[/QUOTE]
It's simple at first, but when you get into const correctness, it gets complicated really quickly.
[url]http://www.parashift.com/c++-faq-lite/const-correctness.html[/url]
[QUOTE=Jooie Kazooie;32199057]C Noob Here:
I am trying to run my program that converts US currency into other currency (such as Yen, Euro, etc.) My program compiles after I get a warning message that says:
[code]
HW2.c: In function `main':
HW2.c:19: warning: passing arg 2 of `convert' from incompatible pointer type.
[/code]
After running it, the only values I get are 0. I have tried everything but I can not figure it out. The code is below and if someone can help me out that would be awesome.
[code]
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
double convert(int dollarinput, int * currentrates);
int main()
{
int dollarinput;
srand(time(NULL));
float currentrates[] = {1.3665 , .9970, 77.3200, 1.5868, rand() % 100};
// Exchange rates as of September 9, 2011, 12:05pm. //
printf("Enter number of dollars:\n");
scanf("%d",&dollarinput);
convert(dollarinput, currentrates);
}
double convert(int dollarinput, int * currentrates)
{
printf("You have %2.2f Euro.\n", currentrates[0] * dollarinput);
printf("You have %2.2f Canadian Dollars.\n", currentrates[1] * dollarinput);
printf("You have %2.2f Yen.\n", currentrates[2] * dollarinput);
printf("You have %2.2f Pounds(GBP).\n", currentrates[3] * dollarinput);
printf("You have %2.2f Fun Dollars.\n",currentrates[4] * dollarinput);
return 0;
}
[/code]
Here is what is looks like when it runs:
[code]
Enter number of dollars:
100
You have 0.00 Euro.
You have 0.00 Canadian Dollars.
You have 0.00 Yen.
You have 0.00 Pounds(GBP).
You have 0.00 Fun Dollars.
[/code]
This is my first time coding C since last May so I am rusty. Please be gentle :)[/QUOTE]
You declared 'currentrates' as int* in the 'convert()' prototype, but you pass float* in the main function. Change it to convert(int dollarinput, float *currentrates);
[QUOTE=ROBO_DONUT;32199518]You declared 'currentrates' as int* in the 'convert()' prototype, but you pass float* in the main function. Change it to convert(int dollarinput, float *currentrates);[/QUOTE]
I had to create another account since it logged me out and I used up all my attempts to get back in my account, but...
Would it be something like this?
[code]
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
convert(int dollarinput, float * currentrates);
int main()
{
int dollarinput;
srand(time(NULL));
float currentrates[] = {1.3665 , .9970, 77.3200, 1.5868, rand() % 100};
// Exchange rates as of September 9, 2011, 12:05pm. //
printf("Enter number of dollars:\n");
scanf("%d",&dollarinput);
[B][U]convert(dollarinput, currentrates);[/U][/B]
}
double convert(int dollarinput, float * currentrates)
{
printf("You have %2.2f Euro.\n", currentrates[0] * dollarinput);
printf("You have %2.2f Canadian Dollars.\n", currentrates[1] * dollarinput);
printf("You have %2.2f Yen.\n", currentrates[2] * dollarinput);
printf("You have %2.2f Pounds(GBP).\n", currentrates[3] * dollarinput);
printf("You have %2.2f Fun Dollars.\n",currentrates[4] * dollarinput);
return 0;
}
[/code]
I used GCC but it didn't compile. Help? (Is it because of the bolded underlined part?)
[QUOTE=JooieKazooie;32201645]I had to create another account since it logged me out and I used up all my attempts to get back in my account, but...
Would it be something like this?
[code]
#include <stdlib.h>
#include <stdio.h>
#include <time.h>
convert(int dollarinput, float * currentrates);
int main()
{
int dollarinput;
srand(time(NULL));
float currentrates[] = {1.3665 , .9970, 77.3200, 1.5868, rand() % 100};
// Exchange rates as of September 9, 2011, 12:05pm. //
printf("Enter number of dollars:\n");
scanf("%d",&dollarinput);
[B][U]convert(dollarinput, currentrates);[/U][/B]
}
double convert(int dollarinput, float * currentrates)
{
printf("You have %2.2f Euro.\n", currentrates[0] * dollarinput);
printf("You have %2.2f Canadian Dollars.\n", currentrates[1] * dollarinput);
printf("You have %2.2f Yen.\n", currentrates[2] * dollarinput);
printf("You have %2.2f Pounds(GBP).\n", currentrates[3] * dollarinput);
printf("You have %2.2f Fun Dollars.\n",currentrates[4] * dollarinput);
return 0;
}
[/code]
I used GCC but it didn't compile. Help? (Is it because of the bolded underlined part?)[/QUOTE]
Up top it should be "double convert" instead of "convert". :smile:
It worked. Thank you so much.
[code]
41
You have 56.03 Euro.
You have 40.88 Canadian Dollars.
You have 3170.12 Yen.
You have 65.06 Pounds(GBP).
You have 3157.00 Fun Dollars.
[/code]
Yay. Now I have to get ready for work :(
I'm trying to think of a program I can make with windows forum (The only area in which I actually have knowledge of at all),I want to make a game, but I have no idea what would be an actually FUN kind of game that would be possible to make with a windows forum, other than a text adventure. Any suggestions?
[editline]10th September 2011[/editline]
Also, is there any easy way to access all outputs from a form object (such as a text box)
[QUOTE=Mr. Smartass;32207810]I'm trying to think of a program I can make with windows forum (The only area in which I actually have knowledge of at all),I want to make a game, but I have no idea what would be an actually FUN kind of game that would be possible to make with a windows forum, other than a text adventure. Any suggestions?
[editline]10th September 2011[/editline]
Also, is there any easy way to access all outputs from a form object (such as a text box)[/QUOTE]
You can't really make much with just windows forms, iirc
[QUOTE=JonBons;32197209]I just joined a robotics team and I'm going to have to learn to use RobotC and LabView. I have the most experience in Lua and PHP, I have done a little bit of C# and C++ but not enough. Any tips? I'm sure the existing programmers can get me up to speed but I don't know too much about their experience.[/QUOTE]
Is this FRC? LabView's easy enough, but it's nothing like coding actual code. I'm subteam lead of Scouting on my team. That way I'm able to utilize my knowledge of PHP and C++. I made a Scantron!
[editline]9th September 2011[/editline]
I'm wondering what kind of team you're on because (AFAIK) RobotC is for LEGO Mindstorms (FLL) or Vex (FTC), but LabView is for FRC's cRIO. I guess technically the basic FLL software is [i]based[/i] off LabView, but I wouldn't count it as the same.
[QUOTE=Agent766;32208085]Is this FRC? LabView's easy enough, but it's nothing like coding actual code. I'm subteam lead of Scouting on my team. That way I'm able to utilize my knowledge of PHP and C++. I made a Scantron![/QUOTE]
Currently I am just doing FTC at the moment but FRC is not out of the question.
[editline]9th September 2011[/editline]
I'm not sure about the other stuff.
I just played around in Virtual Worlds and I seem to have done fine.
[media]http://www.youtube.com/watch?v=KpnLH7NMtsc[/media]
Just a little video I recorded of me playing around, I know its just simple rotations and stuff but at least I'm getting to know the language a bit. Someone on the team explained they were working on a way to map the playing field but they did not have enough time, I think that is where I probably would start to get some problems.
[QUOTE=JonBons;32208102]Currently I am just doing FTC at the moment but FRC is not out of the question.[/QUOTE]
Definitely go for FRC. Totally worth it. I've never regretted all of the time I've dedicated to team. It might be a lot, but it definitely pays off.
[QUOTE=TM Gmod;32196917]Hey. anyone know why this class is throwing an unresolved external?
[code]//code[/code]
my switch in robot update is throwing an unresolved external. anyone see why?[/QUOTE]
I cannot see GetDir being defined.
I just started looking at regex with Python, and this shit's confusing.
I'm trying to take a string '[a:b]' or '[a:b,c]' where a, b, c are numbers and c is optional, and extracting the numbers.
This is as far as I got (note that I replaced the number matching with (.+) and (.*) to shorten it):
[code]r'\[(.+):(.+)[,]\s*(.*)\]'[/code]
It works for [a:b,c], but not for [a:b], while this:
[code]r'\[(.+):(.+)[,]?\s*(.*)\]'[/code]
works for [a:b], but not for [a:b, c].
Any ideas on how to fix this? I'm guessing this is fairly basic, but I'm completely new to regular expressions and it's very unintuitive.
[QUOTE=Anonim;32212991]I just started looking at regex with Python, and this shit's confusing.
I'm trying to take a string '[a:b]' or '[a:b,c]' where a, b, c are numbers and c is optional, and extracting the numbers.
This is as far as I got (note that I replaced the number matching with (.+) and (.*) to shorten it):
[code]r'\[(.+):(.+)[,]\s*(.*)\]'[/code]
It works for [a:b,c], but not for [a:b], while this:
[code]r'\[(.+):(.+)[,]?\s*(.*)\]'[/code]
works for [a:b], but not for [a:b, c].
Any ideas on how to fix this? I'm guessing this is fairly basic, but I'm completely new to regular expressions and it's very unintuitive.[/QUOTE]
Try to make the complete optional part optional:
[CODE]r'\[(.+):(.+)(,\s*(.+))?\]'[/CODE]
You might want to make the extra group not be parsed as a group, though I don't know how that is done in Python's implementation.
Can someone make me a script (Prolly .bat) that you use to rename two different files?
Going to use this for my minecraft.jar, then I can simply click the .bat file on my desktop to change to 1.8 or 1.7.3
[QUOTE=Dienes;32213540]Try to make the complete optional part optional:
[CODE]r'\[(.+):(.+)(,\s*(.+))?\]'[/CODE]
You might want to make the extra group not be parsed as a group, though I don't know how that is done in Python's implementation.[/QUOTE]
This works for '[a:b]', but for '[a:b, c]' it ends up grouping ', c' together with 'b':
[code]>>> r = r'\[(.+):(.+)(,\s*(.+))?\]'
>>> re.search(r,'[0:10, 2]').groups()
('0', '10, 2', None, None)
>>> re.search(r,'[0:10,2]').groups()
('0', '10,2', None, None)[/code]
Sorry, you need to Log In to post a reply to this thread.