iCon
Newish
Posts: 20
|
Post by iCon on Mar 16, 2012 3:08:41 GMT -5
I'm working on a platform game, at the moment it's not much, just a portion of a level, 2 enemies and some water to swim in. On this thread I'll be posting any problems I can't solve.
When I try to spawn a platform as a sprite, it says 'types do not match', I've been using a similar method to spawn the 2 enemies but it won't work in simply setting the sprite's postion. problem solved
EDIT: I will post the most recent version in later posts.
|
|
|
Post by DJLinux on Mar 17, 2012 9:34:36 GMT -5
You should upload the complete source code and images in a zip or rar archive. if you post code with missing variables how we should compile it and point you to the primary problem ?
Joshy
|
|
iCon
Newish
Posts: 20
|
Post by iCon on Mar 17, 2012 21:11:38 GMT -5
New problem, after a set time, the program crashes. It has something to do with the horizontal collision detection function and the player's position. The following attachment is in 7-zip format. Attachments:
|
|
|
Post by shadow008 on Mar 18, 2012 19:24:06 GMT -5
The problem is your platforms.
These lines of code were how i figured it out:
'<<<<<<<<< 'Platforms '>>>>>>>>>
'horizontal platforms for lrloop = 1 to lramount if lrcollision (lrplatform (lrloop).x, lrplatform (lrloop).y, 0, 16) then lrplatform (lrloop).xdir# = -lrplatform (lrloop).xdir# endif
lrplatform (lrloop).x = lrplatform (lrloop).x + lrplatform (lrloop).xdir# next
The problem is that the platform x position is going outside the boundary of what the tiles allow.
When the x platform position reaches 1168, your equation ((xloc + widthhalf)/32) ends up being ((1168 + 16)/32) = 37.
Your tiles x array only goes to 36!!!! I'm not sure how experienced you are with programming, but you cant access data outside of the arrays boundary.
So, fix the platform x movement, heck, fix all objects x movement because the character can go outside those boundarys too.
I suggest you go through and restructure your code and make the following changes:
-Make all objects x&y positions be either all integers or all floats. Dont mix and match. -Change your collision function to preemptively check for faults like accessing data outside array boundarys. -Clamp your objects to the boundarys of the tile array. However you feel like doing so.
Hope that helps you with your problems ^_^
|
|
iCon
Newish
Posts: 20
|
Post by iCon on Mar 20, 2012 1:42:20 GMT -5
I've already found a different solution to the problem. If you look at the enemy code, you'll see that I have an array for the sprites themselves and a structure (in an array) to update the sprites. I only had the structure, not the seperate array, so the loop was updation non-existant platforms, that were located at 0,0 by default. I'm going to attempt some OpenGL before I finish this. Here is the new version (with a checkpoint): Attachments:
|
|