Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Drawing Everything  (Read 25910 times)

0 Members and 1 Guest are viewing this topic.

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Drawing Everything
« Reply #45 on: May 26, 2008, 02:05:08 am »
i keep forgetting to add

im building my program on C: (hard drive) but the flash drive reads as G: on my computer

also, the files are in Flash Drive Root:/Jeopardy

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Drawing Everything
« Reply #46 on: May 26, 2008, 02:07:34 am »
Quote from: "qsik"
i keep forgetting to add

im building my program on C: (hard drive) but the flash drive reads as G: on my computer

also, the files are in Flash Drive Root:/Jeopardy


Tell me what the difference between a relative and an absolute path is.  Also, tell me what a working directory is.

Edit:  To be clear, I'm trying to get you to figure out some of this by yourself.  I'll help you, but I won't do your homework for you.  And to anyone else considering just posting some code, that's not really helping him.

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Drawing Everything
« Reply #47 on: May 26, 2008, 05:21:52 am »
i got it to work, just changed the working directory in the project settings :)

i still dont get the vector2f variable used for the position

dunce

  • Jr. Member
  • **
  • Posts: 77
    • View Profile
Drawing Everything
« Reply #48 on: May 26, 2008, 05:32:37 am »
Returning to this topic title...
IMO, using one-dimention container for representing a kind of render queue is suitable for very simple scenes. In my engine based on sfml I'm mplementing a scene manager with a tree-based scene graph. It is much more complicated, but it gives possibilites for real scene management (transformation, rotation, visibility control, rendering etc.). Scene graphs are mostly considered to be parts of 3d scene managers, but I decided to try them in a 2d engine. In my implementation each nood has a container for child noods based on std::vector. For now I can say nothing about how fast this implementation will be.

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Drawing Everything
« Reply #49 on: May 26, 2008, 05:05:20 pm »
i get it now, ive figured out how to use GetPosition();

quasius and the others, thnx for your help

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Drawing Everything
« Reply #50 on: May 26, 2008, 07:59:51 pm »
strange runtime error! my code checks to see if all images in the column have been clicked and when they are, the top image disappears but clicking on just the last image in the column causes the top image to disappear!

checking code
Code: [Select]

int CheckCategory(int category)
{
int check;
category = category - 1;
int end = category + 30;

for (; category < end;)
{
check = 0 + Jeopardy[category];
category = category + 6;
};

return check;
}


Code: [Select]
bool Clicked(int position, const sf::Input& Input)
{
int MouseX = Input.GetMouseX();
int MouseY = Input.GetMouseY();
bool MouseClicked = Input.IsMouseButtonDown(sf::Mouse::Left);
sf::Vector2f Position = Money[position].GetPosition();

if ((MouseX >= Position.x) && (MouseX <= (Position.x + 170))
&& (MouseY >= Position.y) && (MouseY <= (Position.y + 128))
&& (Jeopardy[position] == 1) && (MouseClicked == true))
return true;
else
return false;
}


         
Code: [Select]
if (Clicked(0, Window.GetInput()) == true)
Jeopardy[0] = 0;
if (Clicked(6, Window.GetInput()) == true)
Jeopardy[6] = 0;
if (Clicked(12, Window.GetInput()) == true)
Jeopardy[12] = 0;
if (Clicked(18, Window.GetInput()) == true)
Jeopardy[18] = 0;
if (Clicked(24, Window.GetInput()) == true)
Jeopardy[24] = 0;


Code: [Select]
if (CheckCategory(1) > 0)
Window.Draw(Categories[0]);


all of Jeopardy's values are set to 1 initially

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Drawing Everything
« Reply #51 on: May 27, 2008, 07:58:42 am »
Obviously hard for me to just guess, but did you set a breakpoint for when you click on the last image and step through the code?  Maybe something is wrong with your function that determines what was clicked.  Maybe you're accidentally using the same index for both images.
You should really take a bit of time to familiarize yourself with breakpoints and the debugger.  They are very powerful and essential in modern code debugging.  You should be able to answer questions like this very quickly with proper breakpoint usage.

Edit:  No problem on the help.  I don't mind helping new programmers.  I just stop short of writing code for them, since I don't think it's really helpful.

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
Drawing Everything
« Reply #52 on: May 29, 2008, 11:53:09 pm »
I don't mean to sound like a jerk, but sometimes the best way to debug your programs is to test them yourself. Most of these problems could have been fixed with thinking or creativity, however I can see why you would ask questions about certain techniques... And quasius has a point, if you write code for someone new, you're doing them a disfavor.

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Drawing Everything
« Reply #53 on: May 30, 2008, 07:52:04 pm »
Quote from: "eleinvisible"
I don't mean to sound like a jerk, but sometimes the best way to debug your programs is to test them yourself. Most of these problems could have been fixed with thinking or creativity, however I can see why you would ask questions about certain techniques... And quasius has a point, if you write code for someone new, you're doing them a disfavor.


Careful...  it's easy to forget what you didn't know when you started programming.  Opening up an IDE like visual studio 2005 for the first time is very intimidating.  It's hard to use breakpoints when you've never heard of breakpoints.
You can point someone in the right direction without giving them the answer, which is helpful.  Yes, you learn by figuring things out yourself.  But a bit more guidance than throwing someone into the deep end and yelling "don't drown!" is useful.

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Drawing Everything
« Reply #54 on: June 02, 2008, 04:41:08 am »
after debugging, i think the check to see if all images in the row are clicked and gone code is incorrect-here it is and its usage

code
Code: [Select]
int CheckCategory(int category)
{
int check;
category = category - 1;
int end = category + 30;

for (; category < end; category = category + 6)
{
check = 0 + Jeopardy[category];
};

return check;
}


usage
Code: [Select]
if (CheckCategory(1) > 0)
Window.Draw(Categories[0]);

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Drawing Everything
« Reply #55 on: June 04, 2008, 09:23:17 pm »
I'm not sure if you're asking a question or telling us you solved it...

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Drawing Everything
« Reply #56 on: June 04, 2008, 11:33:15 pm »
i just wanted ppl to check to see if my code is correct, because im totally lost as why my application is acting this way.

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Drawing Everything
« Reply #57 on: June 05, 2008, 12:26:29 am »
I'm not sure what you think your check function is doing since it's not commented and has no context, but I'm pretty sure the whole thing is equivalent to
Code: [Select]

return Jeopardy[category + 25];


Did you step through the code with breakpoint /watchlist debugging?

qsik

  • Jr. Member
  • **
  • Posts: 60
    • View Profile
Drawing Everything
« Reply #58 on: June 09, 2008, 05:40:35 pm »
i didnt step through debugging cause im a total beginner at that sort of thing...where could i find tutorials?

the clickcheck function checks to see if you clicked on an image then sets the appropriate number in the Jeopardy array as 0. The CheckCategory function adds up all the respective numbers of the specified column of images on the Jeopardy array and if that number is greater than 0, it will draw the category image but if the number is 0, it will not draw the image. clicking on the last image for some reason causes the function to somehow believe the number is 0, even though the other numbers in the array are still 1.

quasius

  • Full Member
  • ***
  • Posts: 166
    • View Profile
Drawing Everything
« Reply #59 on: June 09, 2008, 09:28:41 pm »
Quote from: "qsik"
i didnt step through debugging cause im a total beginner at that sort of thing...where could i find tutorials?


um... google.  I found this in less than a minute: http://www.odetocode.com/Articles/425.aspx

How much time did you spend looking?