Why is a sprite being created without a Draw function?

The Partridge Family were neither partridges nor a family. Discuss.
albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

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

Post by albinopapa » August 14th, 2017, 5:45 am

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;
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

pupperoni
Posts: 12
Joined: August 12th, 2017, 12:56 am

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

Post by pupperoni » August 15th, 2017, 2:40 pm

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:

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

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

Post by albinopapa » August 15th, 2017, 10:16 pm

look into using GitHub. Once you have uploaded to github, you can share the link here.
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

User avatar
chili
Site Admin
Posts: 3948
Joined: December 31st, 2011, 4:53 pm
Location: Japan
Contact:

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

Post by chili » August 16th, 2017, 3:08 am

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.
Chili

pupperoni
Posts: 12
Joined: August 12th, 2017, 12:56 am

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

Post by pupperoni » August 17th, 2017, 12:56 am

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:

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

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

Post by albinopapa » August 17th, 2017, 8:33 pm

Paperboy? Do it lol
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

pupperoni
Posts: 12
Joined: August 12th, 2017, 12:56 am

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

Post by pupperoni » August 26th, 2017, 4:52 pm

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.

OrbitalReign
Posts: 19
Joined: July 17th, 2017, 1:24 pm

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

Post by OrbitalReign » August 27th, 2017, 4:05 am

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;
}

albinopapa
Posts: 4373
Joined: February 28th, 2013, 3:23 am
Location: Oklahoma, United States

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

Post by albinopapa » August 27th, 2017, 8:39 am

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.
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

pupperoni
Posts: 12
Joined: August 12th, 2017, 12:56 am

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

Post by pupperoni » August 27th, 2017, 1:55 pm

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.

Post Reply