Join #ludumdare on irc.afternet.org
Ludum Dare 15 :: Coming in August :: Theme :: ???

Sign In | Write your Journal/Write a Post
Home | Planet Ludum | Rules Wiki | Mailing List

NEWS: Ludum Dare 14 results now available!

View Ludum Dare 14 Results

Posts Tagged ‘help’

Collisions

Posted by SpaceManiac
Monday, October 6th, 2008

I need help with collision code. I want to keep the player from falling through floors, pretty much. Help?

EDIT: Okay, I’ve got some good collision detection, but there’s something wrong with my moving code.

bool checkCollision(SDL_Rect &movable, double &vx, double &vy, SDL_Rect solid, bool move) {
int moveLeft = movable.x;
int moveTop = movable.y;
int moveRight = moveLeft + movable.w;
int moveBottom = moveTop + movable.h;

int solidLeft = solid.x;
int solidTop = solid.y;
int solidRight = solidLeft + solid.w;
int solidBottom = solidTop + solid.h;

int clipLeft = max(moveLeft, solidLeft);
int clipTop = max(moveTop, solidTop);
int clipRight = min(moveRight, solidRight);
int clipBottom = min(moveBottom, solidBottom);

if(clipLeft == clipRight || clipTop == clipBottom)
return false;

if(!move)
return true;

int clipWidth = clipRight - clipLeft;
int clipHeight = clipBottom - clipTop;

if(clipWidth solidX) {
// moving to right
movable.x += solidRight - moveLeft;
} else {
// moving to left
movable.x -= moveRight - solidLeft;
}
} else {
// moving along y axis
vy = 0;
int moveY = moveTop + movable.h / 2;
int solidY = solidLeft + solid.h / 2;
if(moveY > solidY) {
// moving to bottom
movable.y += solidBottom - moveTop;
} else {
// moving to top
movable.y -= moveBottom - solidTop;
}
}

return true;
}

Please help! If you’re interested in seeing what’s happening, here’s the program: http://files.chocoboheaven.com/uploads/Guests/files/85267_PaintWorld.zip

Strange Warnings When Compiling

Posted by SpaceManiac
Monday, August 25th, 2008

Well, this is kind-of compo related, as I’m devoloping my library thing the wiki says I can have. I keep getting these warnings when compiling:

1>c:\program files\microsoft visual studio 8\vc\include\xlocnum(590) : warning C4312:
‘type cast’ : conversion from ‘uintptr_t’ to ‘void *’ of greater size
1> c:\program files\microsoft visual studio 8\vc\include\xlocnum(566) : while
compiling class template member function ’std::istreambuf_iterator<_Elem,_Traits>
std::num_get<_Elem,_InIt>::do_get(_InIt,_InIt,std::ios_base &,std::ios_base::iostate
&,void *&) const’
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits,
1> _InIt=std::istreambuf_iterator>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\xlocnum(1367) : see
reference to class template instantiation ’std::num_get<_Elem,_InIt>’ being compiled
1> with
1> [
1> _Elem=char,
1> _InIt=std::istreambuf_iterator>
1> ]
1>c:\program files\microsoft visual studio 8\vc\include\xlocnum(590) : warning C4312:
‘type cast’ : conversion from ‘uintptr_t’ to ‘void *’ of greater size
1> c:\program files\microsoft visual studio 8\vc\include\xlocnum(566) : while
compiling class template member function ’std::istreambuf_iterator<_Elem,_Traits>
std::num_get<_Elem,_InIt>::do_get(_InIt,_InIt,std::ios_base &,std::ios_base::iostate
&,void *&) const’
1> with
1> [
1> _Elem=wchar_t,
1> _Traits=std::char_traits,
1> _InIt=std::istreambuf_iterator>
1> ]
1> c:\program files\microsoft visual studio 8\vc\include\xlocnum(1373) : see
reference to class template instantiation ’std::num_get<_Elem,_InIt>’ being compiled
1> with
1> [
1> _Elem=wchar_t,
1> _InIt=std::istreambuf_iterator>
1> ]

Anyone know what’s going on, or how to fix it? I’m using SDL and VC++ 2005 Express.

And also, anyone know an easy way to keep <pre> tags inside the column thing? I had to find where it went over and make my own line breaks… And I don’t know if it’ll still look right if you have a different screen resolution. Thanks in advance!

EDIT: Aiee! I give up… I’ll just use some other type of formatting…

Help?

Posted by SpaceManiac
Saturday, August 23rd, 2008

I program gamesĀ and stuff so I thought I would register on this site, but how do I judge? I can’t find the button. Thanks!


All posts, images, and comments are owned by their creators.