• Advertisement
Sign in to follow this  

Why would this array be going out of range? (demo of game+ sorce code + freeware lang

This topic is 4219 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heres the game. Its the executable file called projectSUNDAY. http://www.yousendit.com/transfer.php?action=download&ufid=C5BB36BB2A8EA85D if you want to see the source code I included the freeware of the language I'm using so you can play around with it and see all of my classes. if your jump up into the lave/spike thing theres a cheat to go up and over hte level. Its in this area and this area only (that I can tell) this bug happens. Heres a screen shot of exactly where. http://img155.imageshack.us/img155/5159/bug2wj.png Theres a particular part in my level where the 2 demensional array for my collision map goes out of range when detecting a verticle (down) collision with my main sprite. Heres the specific part of the code. (mind you its in TURING, but should be easy enough to understand) its the line where it accesses the array called map.
 if moveVert = down then     %sprite moved down
            y := oldy (1)
            loop
                if y < newy (1) then     % if y is less than min sprite y its useless
                    y := newy (1)     %sets to sprites min y
                end if
                x := newx (1)
                loop
                    if x > newx (2) then     % if x is bigg than max sprite x its useless
                        x := newx (2)     %sets to sprites max x
                    end if
                    tileDrawn := map (floor (x / TILESIZEX), floor (y / TILESIZEY))
                    if tileDrawn > 1 and tileDrawn < enemy then
                        vertCollision := down     %top of a tile
                        Move_Vert     %goes to proc that moves it out
                    end if
                    exit when x = newx (2)     %gone through sprite width
                    exit when tileDrawn > 1 and tileDrawn < enemy    %leaves if collision is true
                    x += TILESIZEX     %checks next cord on sprites width
                end loop
                exit when y = newy (1)     %permenatly leaves when checked collision on sprites entire motion path
                exit when tileDrawn > 1 and tileDrawn < enemy    %leaves if collision is true
                y -= TILESIZEY     % checks next cord in motion path
            end loop

            if tileDrawn = 1 then
                vertCollision := 0
            end if
EDIT Huh, guess I was wrong then. I took out the really long version so it looks better for you guys. [Edited by - JavaMava on July 3, 2006 11:14:14 PM]

Share this post


Link to post
Share on other sites
Advertisement
your enitre code in a source tag

unit
class CollisionEngine

export Direction_Vert, Direction_Horz, Input_Sprite, Input_Map, ReturnX, ReturnY, ReturnHorzCol, ReturnVertCol,
Revert, ReturnLife, Input_Sprite_Collision, Sprite_Collision_Vert, Sprite_Collision_Horz, Return_Sprite_Collision, ReturnLevel, New_Level

var moveHorz, moveVert, x, y, done : int := 0
var right, left, up, down, static, downLeft, downRight : int := 0

var newx, newy, oldx, oldy : array 1 .. 2 of int %These variables are the surrounding collision box cordinates of the character
var spriteX1, spriteWidth, spriteY1, spriteHeight : int

var vertCollision, horzCollision : int := static

var spriteCollision, hurt, kill, enemy : int := 0
hurt := 1
kill := 2
enemy := 6 %tells what tiles are enemies so you can ignor collision

var width, height : int
var life, nextLevel : boolean := false

var MAPTILEX := 300 %amount of x tiles in the entire map
var MAPTILEY := 200 %amount of y tiles in the entire map

var TILESIZEX := 16 %Size of x tile in pixels
var TILESIZEY := 16 %Size of x tile in pixels

var SCREENHIEGHT := 28 %number of tile up on screen at once
var SCREENWIDTH := 44 %number of tile across on screen at once

var map : array 0 .. MAPTILEX, 0 .. MAPTILEY of int

var Collisiontiles : int
var tiles : array 1 .. 7 of int
var selectedTile : int := 1
var tileDrawn := 0
var temp := 0

var count : int := 0

const numOfTiles := 7

right := 1
left := 2
up := 3
down := 4
static := 0
var level := 1

var fileName : string := "TestMap" % Name of file
fileName := "collision" + intstr (level)
var fileNo : int % Number of file
open : fileNo, fileName, read
read : fileNo, map
close : fileNo


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc New_Level (l : int)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

level := l
fileName := "collision" + intstr (level)

open : fileNo, fileName, read
read : fileNo, map
close : fileNo

end New_Level
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Move_Vert %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

life := false
nextLevel := false

if tileDrawn = 2 then %top collsions
if vertCollision = down then
newy (1) := ((floor (y / TILESIZEY) + 1) * TILESIZEY)
end if
elsif tileDrawn = 3 then %all sides collide
if vertCollision = down then
newy (1) := ((floor (y / TILESIZEY) + 1) * TILESIZEY)
elsif vertCollision = up then
newy (1) := ((newy (1) - (newy (2) - ((floor (y / TILESIZEY) * TILESIZEY)))) - 1) %moves the rect down too outside the tile
end if
elsif tileDrawn = 4 then %angled up right
if vertCollision = down then
newy (1) := ((floor (y / TILESIZEY) + 1) * TILESIZEY)
elsif vertCollision = up then
newy (1) := ((newy (1) - (newy (2) - ((floor (y / TILESIZEY) * TILESIZEY)))) - 1) %moves the rect down too outside the tile
end if
life := true
elsif tileDrawn = 5 then
nextLevel := true
end if

newy (2) := newy (1) + height

oldy (1) := newy (1)
oldy (2) := newy (2)

end Move_Vert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Move_Horz %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

life := false
nextLevel := false

if tileDrawn = 3 then
if horzCollision = right then
newx (1) := ((newx (1) - (newx (2) - ((floor (x / TILESIZEX) * TILESIZEX)))) - 1) %moves the rect down too outside the tile
newx (2) := newx (1) + width
elsif horzCollision = left then
newx (1) := ((floor (x / TILESIZEX) + 1) * TILESIZEX)
newx (2) := newx (1) + width
end if
elsif tileDrawn = 4 then
if horzCollision = right then
newx (1) := ((newx (1) - (newx (2) - ((floor (x / TILESIZEX) * TILESIZEX)))) - 1) %moves the rect down too outside the tile
newx (2) := newx (1) + width
elsif horzCollision = left then
newx (1) := ((floor (x / TILESIZEX) + 1) * TILESIZEX)
newx (2) := newx (1) + width
end if
life := true
else
horzCollision := 0
end if

oldx (1) := newx (1)
oldx (2) := newx (2)

end Move_Horz
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc What_Tile_Horz %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if moveHorz = left then
x := oldx (1)
loop
if x < newx (1) then
x := newx (1)
end if
y := newy (1)
loop
if y > newy (2) then
y := newy (2)
end if
tileDrawn := map (floor (x / TILESIZEX), floor (y / TILESIZEY))
if tileDrawn > 1 and tileDrawn < enemy then
horzCollision := left
Move_Horz
end if
exit when y = newy (2)
exit when tileDrawn > 1 and tileDrawn < enemy
y += TILESIZEY
end loop
exit when x = newx (1)
exit when tileDrawn > 1 and tileDrawn < enemy
x -= TILESIZEX
end loop

if tileDrawn = 1 then
horzCollision := 0
end if

elsif moveHorz = right then
x := oldx (2)
loop
if x > newx (2) then
x := newx (2)
end if
y := newy (1)
loop
if y > newy (2) then
y := newy (2)
end if
tileDrawn := map (floor (x / TILESIZEX), floor (y / TILESIZEY))
if tileDrawn > 1 and tileDrawn < enemy then
horzCollision := right
Move_Horz
end if
exit when y = newy (2)
exit when tileDrawn > 1 and tileDrawn < enemy
y += TILESIZEY
end loop
exit when x = newx (2)
exit when tileDrawn > 1 and tileDrawn < enemy
x += TILESIZEX
end loop

if tileDrawn = 1 then
horzCollision := 0
end if

end if

end What_Tile_Horz
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc What_Tile_Vert %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if moveVert = down then %sprite moved down
y := oldy (1)
loop
if y < newy (1) then % if y is less than min sprite y its useless
y := newy (1) %sets to sprites min y
end if
x := newx (1)
loop
if x > newx (2) then % if x is bigg than max sprite x its useless
x := newx (2) %sets to sprites max x
end if
tileDrawn := map (floor (x / TILESIZEX), floor (y / TILESIZEY))
if tileDrawn > 1 and tileDrawn < enemy then
vertCollision := down %top of a tile
Move_Vert %goes to proc that moves it out
end if
exit when x = newx (2) %gone through sprite width
exit when tileDrawn > 1 and tileDrawn < enemy %leaves if collision is true
x += TILESIZEX %checks next cord on sprites width
end loop
exit when y = newy (1) %permenatly leaves when checked collision on sprites entire motion path
exit when tileDrawn > 1 and tileDrawn < enemy %leaves if collision is true
y -= TILESIZEY % checks next cord in motion path
end loop

if tileDrawn = 1 then
vertCollision := 0
end if

elsif moveVert = up then
y := oldy (2)
loop
if y > newy (2) then
y := newy (2)
end if
x := newx (1)
loop
if x > newx (2) then
x := newx (2)
end if
tileDrawn := map (floor (x / TILESIZEX), floor (y / TILESIZEY))
if tileDrawn > 1 and tileDrawn < enemy then
vertCollision := up
Move_Vert
end if
exit when x = newx (2)
exit when tileDrawn > 1 and tileDrawn < enemy
x += TILESIZEX
end loop
exit when y = newy (2)
exit when tileDrawn > 1 and tileDrawn < enemy
y += TILESIZEY
end loop

if tileDrawn = 1 then
vertCollision := 0
end if

end if


end What_Tile_Vert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Direction_Vert %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if newy (1) > oldy (1) then % up
moveVert := up
What_Tile_Vert
elsif newy (1) < oldy (1) then %down
moveVert := down
What_Tile_Vert
end if

end Direction_Vert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Direction_Horz %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if newx (1) > oldx (1) then % right
moveHorz := right
What_Tile_Horz
elsif newx (1) < oldx (1) then %left
moveHorz := left
What_Tile_Horz
end if

end Direction_Horz
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Input_Sprite (nx1, ox1, ny1, oy1, h, w : int) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

height := h
width := w

newx (1) := nx1
newx (2) := newx (1) + width
oldx (1) := ox1
oldx (2) := oldx (1) + width

newy (1) := ny1
newy (2) := newy (1) + height
oldy (1) := oy1
oldy (2) := oldy (1) + height

end Input_Sprite
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Input_Map (tsx, tsy, mtx, mty, sh, sw : int, fn : string) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

MAPTILEX := mtx %amount of x tiles in the entire map
MAPTILEY := mty %amount of y tiles in the entire map

TILESIZEX := tsx %Size of x tile in pixels
TILESIZEY := tsy %Size of x tile in pixels

SCREENHIEGHT := sh %number of tile up on screen at once
SCREENWIDTH := sw %number of tile across on screen at once

var map : array 0 .. MAPTILEX, 0 .. MAPTILEY of int

var fileName : string := fn % Name of file
var fileNo : int % Number of file
open : fileNo, fileName, read
read : fileNo, map
close : fileNo

end Input_Map
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Input_Sprite_Collision (sX1, sWi, sY1, sH, pX1, pY1, pW, pH, poX1, poY1 : int) %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

spriteX1 := sX1
spriteWidth := sWi
spriteY1 := sY1
spriteHeight := sH

height := pH
width := pW

newx (1) := pX1
newx (2) := newx (1) + pW
oldx (1) := poX1
oldx (2) := oldx (1) + pW

newy (1) := pY1
newy (2) := newy (1) + pH
oldy (1) := poY1
oldy (2) := oldy (1) + pH

end Input_Sprite_Collision
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Sprite_Collision_Horz %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

spriteCollision := 0

if newx (1) > oldx (1) then % char moved right
if newx (1) >= spriteX1 and newx (1) <= (spriteX1 + spriteWidth) then
if newy (1) >= spriteY1 and newy (1) <= (spriteY1 + spriteHeight) then
spriteCollision := left
elsif newy (2) >= spriteY1 and newy (2) <= (spriteY1 + spriteHeight) then
spriteCollision := left
end if
elsif newx (2) >= spriteX1 and newx (2) <= (spriteX1 + spriteWidth) then
if newy (1) >= spriteY1 and newy (1) <= (spriteY1 + spriteHeight) then
spriteCollision := left
elsif newy (2) >= spriteY1 and newy (2) <= (spriteY1 + spriteHeight) then
spriteCollision := left
end if
end if
elsif newx (1) < oldx (1) then %moves left
if newx (1) >= spriteX1 and newx (1) <= (spriteX1 + spriteWidth) then
if newy (1) >= spriteY1 and newy (1) <= (spriteY1 + spriteHeight) then
spriteCollision := right
elsif newy (2) >= spriteY1 and newy (2) <= (spriteY1 + spriteHeight) then
spriteCollision := right
end if
elsif newx (2) >= spriteX1 and newx (2) <= (spriteX1 + spriteWidth) then
if newy (1) >= spriteY1 and newy (1) <= (spriteY1 + spriteHeight) then
spriteCollision := right
elsif newy (2) >= spriteY1 and newy (2) <= (spriteY1 + spriteHeight) then
spriteCollision := right
end if
end if
end if

end Sprite_Collision_Horz
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
proc Sprite_Collision_Vert %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

spriteCollision := 0

if newy (1) >= oldy (1) then
if newy (1) >= spriteY1 and newy (1) <= (spriteY1 + spriteHeight) then
if newx (1) >= spriteX1 and newx (1) <= (spriteX1 + spriteWidth) then
spriteCollision := up
elsif newx (2) >= spriteX1 and newx (2) <= (spriteX1 + spriteWidth) then
spriteCollision := up
end if

elsif newy (2) >= spriteY1 and newy (2) <= (spriteY1 + spriteHeight) then
if newx (1) >= spriteX1 and newx (1) <= (spriteX1 + spriteWidth) then
spriteCollision := up
elsif newx (2) >= spriteX1 and newx (2) <= (spriteX1 + spriteWidth) then
spriteCollision := up
end if
end if

elsif newy (1) <= oldy (1) then
if newy (1) >= spriteY1 and newy (1) <= (spriteY1 + spriteHeight) then
if newx (1) >= spriteX1 and newx (1) <= (spriteX1 + spriteWidth) then
spriteCollision := down
elsif newx (2) >= spriteX1 and newx (2) <= (spriteX1 + spriteWidth) then
spriteCollision := down
end if
elsif newy (2) >= spriteY1 and newy (2) <= (spriteY1 + spriteHeight) then
if newx (1) >= spriteX1 and newx (1) <= (spriteX1 + spriteWidth) then
spriteCollision := down
elsif newx (2) >= spriteX1 and newx (2) <= (spriteX1 + spriteWidth) then
spriteCollision := down
end if
end if
end if

end Sprite_Collision_Vert
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function Return_Sprite_Collision : int %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

result spriteCollision

end Return_Sprite_Collision
%%%%%%%%%%%%%%%%%%%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%%%%%%%%%%%%%

result horzCollision

end ReturnHorzCol
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function ReturnLife : boolean %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

result life

end ReturnLife
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function ReturnLevel : boolean %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

if count = 1 then
nextLevel := false
count := 0
elsif nextLevel = true then
count := 1
end if
result nextLevel


end ReturnLevel
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%



end CollisionEngine

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
OK, you can stop bumping
the reason you arent getting replies is because you're just asking someone to find a bug

finding bugs is not fun at all, so no one's volunteering.

if you ask a more general question about perhaps, good approaches to debugging
or clever techniques for dealing with arrays
then you might get some nice inputs
but no one really cares about doing the 'bitch work' of your coding

as near as we can tell, you have no conceptual difficulties here(learning is what this place is for), its just a matter of finding a mistake someplace in your code; and since you're the most familiar with that stuff you're actually the best candidate to do it

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement