Main Menu

Super Mario Chain and Ball question

Started by Andreas, May 31, 2008, 02:46:06 PM

Previous topic - Next topic

Andreas

Ok so I'm trying to make a Mario Chain and ball.  I want to be able to pull the chain out from a point and have it extend. Like a vacume cleaner power cord.

Here's code

type tSegment

x#
y#
z#

sprite

endtype


type tChain

startX#
startY#

endX#
endY#

angle#

maxLength#

seg(1) as tSegment
segTotal

endtype

dim chain(1) as tChain

setupChain(5,10)

sync
waitkey
end

function setupChain( segLength#,segTotal )


thisChain= getfreecell( chain() )

for lp =1 to segTotal

chain(thisChain).seg() =new tSegment

freeSprite=getfreesprite()
createsprite freeSprite

; This is so not allowed, so how am I suppose to do it right?

chain(thisChain).seg().sprite =freesprite

print freesprite

next


endfunction




So how do i accsess and create the seg() dimensions of my chain()?

Or is this not the way to do it at all?

any tips would be very helpfull...  ;D


andreas
The best thing about making space shooters is that space, is easy to draw.

hartnell

you may need to include an array index for seg.


;each chain has 4 segments
For i = 1 to 4
    chain(thisChain).seg(i).sprite
Next


Note, I didn't test the code because I assumed you would understand the concept. If you want me to, I will. :)

-- hartnell

Andreas

#2
This was my thought aswell



type tSegment

sprite

endtype


type tChain

seg(10) as tSegment

endtype

dim chain(1) as tChain


thisChain=1

For i = 1 to 4
    chain(thisChain).seg(i).sprite = 1
Next



"chain(thisChain).seg(i).sprite"
generates a syntax error.
The best thing about making space shooters is that space, is easy to draw.

kevin


Typed Array fields are not supported.

Andreas

The best thing about making space shooters is that space, is easy to draw.

hartnell

Let me know if you find a workable solution to this. If not, I'll give it a shot.

-- shawn

Andreas

#6
Thanks. It was more of a assignment to my self to learn more about a method of handeling many objects.
So I need to keep steam on the learning process if I am to win the adventure game compo.. :)

Witch brings me to my next question: Is there something fishy with SpriteHitWorld() ? I can't get it to return anything but 'false'. And the example that's in the help docs doesn't work. but then again i'm using PB1.71 maybe that's the prob. Or maybe it's my ineptitude witch also get's in my way from time to time. ;p

openscreen 640,480,32,1

Explicit
Declaration
WORLD
SPRITE
CAMERA
IMAGE

MX
MY
EndDeclaration

WORLD=1
SPRITE=1
CAMERA=1
IMAGE=1

;create World and Camera
createworld WORLD
capturetoworld WORLD

box 0,0,640,100,1
PartitionWorld WORLD,32

createcamera CAMERA

;create The Sprite
DrawGFXImmediate

ink rgb(0,0,255)
box 0,0,30,30,1
getimage IMAGE,0,0,30,30
preparefximage IMAGE

createsprite SPRITE
spriteimage SPRITE,IMAGE
spritedrawmode SPRITE,2
spritecollisionmode SPRITE,1
spritecollisionworld SPRITE,WORLD


repeat

MX=mousex()
MY=mousey()

capturetoscene
clsscene

positionsprite SPRITE,MX,MY
drawallsprites

cameragrabworld CAMERA,WORLD
drawcamera CAMERA

;if we get hit, it all ends
if spritehitworld(SPRITE)
continue
endif

sync

until esckey()
end


Andreas
The best thing about making space shooters is that space, is easy to draw.

Andreas

Forget it. I'm an idiot...  ::) I will be using 1.63 from now on  ;D

andreas
The best thing about making space shooters is that space, is easy to draw.