Page 2 of 3

Re: Why is a sprite being created without a Draw function?

Posted: August 14th, 2017, 5:45 am
by albinopapa

Code: Select all

	return
		forward_left_overlap <= bone_right_overlap&&
		forward_right_overlap >= bone_left_overlap&&
		forward_top_overlap <= bone_bottom_overlap&&
		forward_bottom_overlap >= bone_top_overlap;

	return
		backward_left_overlap <= bone_right_overlap&&
		backward_right_overlap >= bone_left_overlap&&
		backward_top_overlap <= bone_bottom_overlap&&
		backward_bottom_overlap >= bone_top_overlap;
The second return won't get processed. Function will only return the result of the first block.

Code: Select all

	GameisStarted = wnd.kbd.KeyIsPressed( VK_RETURN );
This means that the game ends when VK_RETURN is not pressed, because GameIsStarted will be false unless you holding enter.

Code: Select all

	left = wnd.kbd.KeyIsPressed( VK_LEFT );
This means show the forward facing, even if not pressing any buttons.
In your IsCollidingForward and IsCollidingBackward functions you have:

Code: Select all

	int bright = bx + bWidth;
	int bbottom = by + bHeight;
	int tright = tx + tWidth;
	int tbottom = ty + tHeight;

	return
		bright >= tx&&
		tx <= tright&&		// I think it should be: bx <= tright &&
		bbottom >= ty&&
		by <= tbottom;

Re: Why is a sprite being created without a Draw function?

Posted: August 15th, 2017, 2:40 pm
by pupperoni
Thanks, your comment was correct! I had a couple other bugs with the collision but after about 7 hours I finally fixed them all lol (and got rid of unnecessary code)

But now my dog game is a success! I wanted to upload it here but even with only the Engine and License folders and the .sln, it was 14.7 mb :cry:

Re: Why is a sprite being created without a Draw function?

Posted: August 15th, 2017, 10:16 pm
by albinopapa
look into using GitHub. Once you have uploaded to github, you can share the link here.

Re: Why is a sprite being created without a Draw function?

Posted: August 16th, 2017, 3:08 am
by chili
There are files that need cleaning in engine folder as well.
All you need is the exe and any sounds / image files your exe loads.

Re: Why is a sprite being created without a Draw function?

Posted: August 17th, 2017, 12:56 am
by pupperoni
Alright, I had to upload a slightly older version but it is nonetheless fully functional. Here's the github link. I mean, it's 100% the poo game but with a dog but nonetheless...I learned to do it in 3 days and I'm proud. :D I physically counted/mapped the pixels for the dog + bone sprites, but I used Tristan's "image2chilicode" for the title/game over.

I think I might add a little doghouse as an endpoint, so you have to collect all the bones then get to the dog house to complete the "level".

I feel like I'm one background away from Paperboy. :lol:

Re: Why is a sprite being created without a Draw function?

Posted: August 17th, 2017, 8:33 pm
by albinopapa
Paperboy? Do it lol

Re: Why is a sprite being created without a Draw function?

Posted: August 26th, 2017, 4:52 pm
by pupperoni
I am driving myself crazy. I watched through tutorial 12/homework 12, and I encapsulated my code. However, now the random generator is throwing numbers way too big. I went to the wiki page for 13 and downloaded the starting code to compare to what I have.

game.h and game.cpp were exactly the same except that I only used bone#(xDist(rng), yDist(rng)) and instead of including vx/vy because I'm not interested in having the bones move. Also, instead of 770/570 I used gfx.ScreenWidth-12 and gfx.ScreenHeight-7 but when I changed the numbers to 785 and 590 it still threw larger numbers.

My code is here, under Dog-Encapsulation.

I tried debugging and I see that the x variables are being set to monstrous numbers, but I'm at a loss on how to fix. I thought I'd try a cheap fix and make a ClampToScreen function for Bone, but that failed as well. I copied/pasted the tutorial 13 rng code (obviously changing "poo" to "bone") but it still fails.

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 4:05 am
by OrbitalReign
If your still pulling your hair out
rethink what this is doing.

Code: Select all

Bone::Bone(int in_x, int in_y)
{
	in_x = x;
	in_y = y;
}

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 8:39 am
by albinopapa
OrbitalReign wrote:If your still pulling your hair out
rethink what this is doing.

Code: Select all

Bone::Bone(int in_x, int in_y)
{
	in_x = x;
	in_y = y;
}
I was going to post this, but I had to leave before I did, anyway, good catch orbital.

Re: Why is a sprite being created without a Draw function?

Posted: August 27th, 2017, 1:55 pm
by pupperoni
I assume the constructor function sets the "x" variable. So first the rng generates a number (with the help of rd) between 0 and 788, which is then put into the in_x spot because of bone#(xDist(rng), yDist(rng)). That sets "x" to that random number, which is then called by bone#.Draw

Every time I debug, it always takes me to the Draw function because the variables are too big.

So I had assumed that the rng was ignoring the constraints of 0,gfx.ScreenWidth-12 and 0,gfx.ScreenHeight-7.