Hi anybody can helpme anbout make dynamic array, whit types, witout types I succes the code, but whit types on variables and Dimpush I don´t understand very well how make the code.
Thanks for your time,
Kinds Regards,
Iván Jiménez.
what you want? dont understand the question right...
HI Schranz0r, the first thanks for reply.
What I want is make the shot of spacial ship, the tipically shot of arcade machines.
I make the code whit Dimpush for make a dinamyc array, this works well, and delete the first entry at the end of the screen for no busy the stack of arrays, in this point all is ok, but I want make the same but whit an array whit a type in example.
Type SpriteT
x;
y;
endtype
global shot[] as spriteT
making a type of array I don´t kwon how make the shot, I can made whit sepaated arrays, but I want learn how make whit types.
Thanks Schranz0r, for your time for been reply.
Best Regards, Iván J.
Hi mentalthink...
TYPE tObject
x
y
ENDTYPE
global newO as tObject
global O[] as tObject
while true
if timer<gettimerall()
newO.x=rnd(400)
newO.y=0
dimpush newO,O[]
timer=gettimerall()+1000
endif
foreach Check in O[]
inc Check.y,5
print "Check",Check.x,Check.y
if Check.y>500 then delete Check
next
showscreen
wend
Do you mean sth. like this?
greets
HI BackSlider, this code help a lot of.
I tried but nothing apperars on screen :rant:, but the code help me too much whit the foreach command.
I stay making some changes, I hope can be uploaded in a short time, but I stay two days for make this tiny code, I think a little more... and my brain fry.
Thanks again, Backslider, is very , very helpfull your code.
Best Regards, and thanks,
Iván J.
yes sry you cant see anything xD
i forgot the dimpush command ;)
use the updated code and try again.
it should work (im writing from phone so i cant test)
Ok Backslider don´t woorry, not is a great trouble.
I made this code, I thinks works, thanks for your help, I´m not programmer and in some cases I do too much turns for search a apropiate code.
Well I write this, and it´s waht I want.
TYPE tObject
x
y
c
ENDTYPE
GLOBAL newO AS tObject
GLOBAL O[] AS tObject
DIM O[1]
newO.c=1
WHILE TRUE
MOUSESTATE mx,my,b1,b2
IF mx<=319
IF KEY(57)
INC time,1
IF time=3 OR time=5
DIMPUSH O[],newO
a=a+1
O[a].x=mx
O[a].y=my
ELSE
IF time>=6 THEN time=0
ENDIF
ENDIF
ENDIF
FOR p=0 TO LEN(O[])-1
PRINT LEN(O[])-1,100,1+(LEN(O[])-1*3)
NEXT
FOREACH Check IN O[]
INC Check.x,5
PRINT "Check",Check.x,Check.y
IF Check.x>=320 //AND Check.y<=202
a=a-1
DELETE Check
DIMDEL O[],1
ENDIF
// PRINT e,200,0
NEXT
//test array
SHOWSCREEN
WEND
Thanks, your code open my Mind :nw:
kind Regards,
Iván J.