Beginner C++ Game Programming DirectX Tutorial 5

The Partridge Family were neither partridges nor a family. Discuss.
Post Reply
what on earth
Posts: 3
Joined: August 18th, 2017, 10:25 am

Beginner C++ Game Programming DirectX Tutorial 5

Post by what on earth » August 18th, 2017, 10:32 am

Hi everyone,
I've been trying to solve the problem of the cursor hitting the edges of the screen
so i did exactly what chili did in the video https://www.youtube.com/watch?v=UREKHWv ... m1w03c010c 9:40
I set the values and everything to the same he did but my program still crashes when it hits the bottom of the screen , I wonder if someone could help me figure out the reason :
if (x + 5 > gfx.ScreenWidth) {
x = gfx.ScreenWidth - 6;
vx = 0;
}

if (y + 5 >= gfx.ScreenHeight) {
y = gfx.ScreenWidth -6;
vy = 0;
}

if (y - 5 < 0) {
y = 5;
vy = 0;
}

if (x - 5 < 0) {
x = 5;
vx = 0;
}

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

Re: Beginner C++ Game Programming DirectX Tutorial 5

Post by chili » August 18th, 2017, 10:34 am

if (y + 5 >= gfx.ScreenHeight) {
y = gfx.ScreenWidth -6;
vy = 0;
}

Exactly what I did huh? ;)
Chili

what on earth
Posts: 3
Joined: August 18th, 2017, 10:25 am

Re: Beginner C++ Game Programming DirectX Tutorial 5

Post by what on earth » August 18th, 2017, 10:37 am

chili wrote:if (y + 5 >= gfx.ScreenHeight) {
y = gfx.ScreenWidth -6;
vy = 0;
}

Exactly what I did huh? ;)

OMG I've been trying for like an hour or so :shock:
thank you so much :D

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

Re: Beginner C++ Game Programming DirectX Tutorial 5

Post by chili » August 18th, 2017, 10:54 am

Np bro. You just ask the same question in the comments btw?
Chili

what on earth
Posts: 3
Joined: August 18th, 2017, 10:25 am

Re: Beginner C++ Game Programming DirectX Tutorial 5

Post by what on earth » August 18th, 2017, 11:08 am

chili wrote:Np bro. You just ask the same question in the comments btw?
Yes ! I accidentally deleted my reply on my comment so I couldn't see if i got replies so I just asked here again.

Post Reply