Homework #5 Help
-
- Posts: 4373
- Joined: February 28th, 2013, 3:23 am
- Location: Oklahoma, United States
Re: Homework #5 Help
bool Game::collide(Rectangle A, Rectangle B)
See the bool at the beginning? That means the function needs to return a bool, either true or false. You return a value by preceding the value with the keyword return
return true;
or
return false;
See the bool at the beginning? That means the function needs to return a bool, either true or false. You return a value by preceding the value with the keyword return
return true;
or
return false;
If you think paging some data from disk into RAM is slow, try paging it into a simian cerebrum over a pair of optical nerves. - gameprogrammingpatterns.com
Re: Homework #5 Help
Oh derp, you can change the bool to void. my bad ... I shouldn't really direct anyone lol. I often make mistakes
Sorry
Sorry
Curiosity killed the cat, satisfaction brought him back
Re: Homework #5 Help
Thank you albinopapa and MrGodin!
MrGodin! We're all in this together my friend!
MrGodin! We're all in this together my friend!
Re: Homework #5 Help
Hey there again gents! I'm sorry for making this an entire episode.
MrGodin, I'm sure you are familiar with my question earlier about why my reticle is not this navy blue color when I press control? Also, the reason why my moving box changes to the color red way before it touches the stationary box. (It changes color to red on the right side of the stationary box)
I have tried changing the color schemes to different variables and things of that nature, but the box would be purple, black and sometimes no color at all.
I have attached my file again so you can see the error. Thank you guys!
MrGodin, I'm sure you are familiar with my question earlier about why my reticle is not this navy blue color when I press control? Also, the reason why my moving box changes to the color red way before it touches the stationary box. (It changes color to red on the right side of the stationary box)
Code: Select all
gfx.PutPixel(-5 + x, -5 + y, rg,gb,gb);
gfx.PutPixel(-5 + x, -4 + y, rg,gb,gb);
gfx.PutPixel(-5 + x, -3 + y, rg,gb,gb);
gfx.PutPixel(-4 + x, -5 + y, rg,gb,gb);
gfx.PutPixel(-3 + x, -5 + y, rg,gb,gb);
gfx.PutPixel(-5 + x, 5 + y, rg,gb,gb);
gfx.PutPixel(-5 + x, 4 + y, rg,gb,gb);
gfx.PutPixel(-5 + x, 3 + y, rg,gb,gb);
gfx.PutPixel(-4 + x, 5 + y, rg,gb,gb);
gfx.PutPixel(-3 + x, 5 + y, rg,gb,gb);
gfx.PutPixel(5 + x, -5 + y, rg,gb,gb);
gfx.PutPixel(5 + x, -4 + y, rg,gb,gb);
gfx.PutPixel(5 + x, -3 + y, rg,gb,gb);
gfx.PutPixel(4 + x, -5 + y, rg,gb,gb);
gfx.PutPixel(3 + x, -5 + y, rg,gb,gb);
gfx.PutPixel(5 + x, 5 + y, rg,gb,gb);
gfx.PutPixel(5 + x, 4 + y, rg,gb,gb);
gfx.PutPixel(5 + x, 3 + y, rg,gb,gb);
gfx.PutPixel(4 + x, 5 + y, rg,gb,gb);
gfx.PutPixel(3 + x, 5 + y, rg,gb,gb);
I have attached my file again so you can see the error. Thank you guys!
- Attachments
-
- C++ Homework 5.zip
- (2.93 KiB) Downloaded 123 times
Re: Homework #5 Help
is because of thisAlso, the reason why my moving box changes to the color red way before it touches the stationary box. (It changes color to red on the right side of the stationary box)
Code: Select all
if (bx <= 200)
{
rb = 0;
}
else
{
rb = 255;
}
The color change on Control press
Code: Select all
if (wnd.kbd.KeyIsPressed(VK_CONTROL))
{
rg = 0;
}
else
{
rg = 255;
}
you blend colors RGB together. Each color value of r,g,b range from 0-255.
So if you go rb = 255, gb = 255, bb = 255 will equal white.
i noticed in you putpixel calls gfx.PutPixel(-5 + x, -5 + y, rg, gb, gb); the rg(red),gb(green),gb(blue) Your blue will be the same vale as green because they are both gb. Do you see ?:).
here you also had
Code: Select all
A.left = x + -5; A.right = x + 5; A.top = y - 5; A.bottom = y + 5;
B.left = bx + -5; B.right = by + 5;<****ERROR***** B.top = by - 5; B.bottom = by + 5;
Curiosity killed the cat, satisfaction brought him back
Re: Homework #5 Help
I have updated your Game files
What i did in Game.h is relabeled you color values to red, green blue for the reticle
and box_red, box_blue,box_green for the Box.
In Game.cpp i removed the code that makes you reticle change to red when you don want it to
I also updated your putpixel calls with the appropriate color values
I did this to better follow colors so you can see how it is all working
You can now play around with the colors and get the ones you want, which i suggest you do for practice,
have fun
What i did in Game.h is relabeled you color values to red, green blue for the reticle
and box_red, box_blue,box_green for the Box.
In Game.cpp i removed the code that makes you reticle change to red when you don want it to
I also updated your putpixel calls with the appropriate color values
I did this to better follow colors so you can see how it is all working
You can now play around with the colors and get the ones you want, which i suggest you do for practice,
have fun
- Attachments
-
- Game.zip
- (2.61 KiB) Downloaded 122 times
Curiosity killed the cat, satisfaction brought him back
Re: Homework #5 Help
Wow! I am completely astonished! Everything we have learned from past videos are simply basic foundations in which we can build to make a whole lot better.
Thank you, MrGodin! I am very appreciative of your help and service to the community. I'm going to make note of these in my notebook and practice with them before I move on to the next tutorial. Thank you again, my friend!
Thank you, MrGodin! I am very appreciative of your help and service to the community. I'm going to make note of these in my notebook and practice with them before I move on to the next tutorial. Thank you again, my friend!
Re: Homework #5 Help
One last thing!
Is "void Game::collide" a class? I was wondering why and when we would declare this.
Is "void Game::collide" a class? I was wondering why and when we would declare this.
Re: Homework #5 Help
void Game::collide(...) is a function definition. it defines the body of a function that was declared inside the class Game.
Chili
Re: Homework #5 Help
I see! So after "Game::" we define pretty much whatever we want? Like collide? Uppercut? Fart and such?