im sorry for asking too much help but seriously i need it :$
The problem:
I´m looking to open a file and read a variable inside of it and use it inside the code, if another variable is bigger, then equialize them
PSEUDO-CODE
variable1=READFILE "file.txt",line
variable2=10
IF variable1<variable2
variable2=WRITEFILE "file.txt",line
ENDIF
something like that
The easiest way would be something like :
IF OPENFILE(1,"test.dat",1)
READLONG 1,variable1
CLOSEFILE 1
IF variable1<variable2
IF OPENFILE(1,"test.dat",0)
WRITELONG 1,variable2
CLOSEFILE 1
ENDIF
ENDIF
ENDIF
Or could use INI files :
INIOPEN "test.ini"
variable1=INIGET$("VARIABLE","VAR","")
IF variable1<variable2 THEN INIPUT "VARIABLE","VAR",variable2
INIOPEN ""
thank you so much, i can store text right? like "hello world"?
and i got another question but is not about files...
How do i make an animation that loops?
Is there a way to get collision coordinates? thanks :D
thank you so much, i can store text right? like "hello world"?
Yes , you can use WriteSTR (in fact always use this method)...
and i got another question but is not about files...
How do i make an animation that loops?
Is there a way to get collision coordinates? thanks :D
For make loops in animations it's very easy.... Imagine you make 25 Frames (I use always this numbers of Frames, are totally enough for a smooth animation)...
Basically I do an Atlas image it's much better than use image per image... it's more clear your media Folder (I think in Spanish forum I put a code for my Internal tool for make this Atlas... If don't find it, comment me and I send you thru PM)
Well the core for make an animation whit loop it's very easy , you only need a counter...
static n_Frame
if n_Frame<25
inc n_Frame, 0.5 (This it's the speed to reproduce the Frames)
else
n_Frame = 0
endif
drawanim my_Sequence, n_Frame, pos_X, pos_Y
or
drasprite n_Frame , pos_X, pos_Y
for get coordinates where collide something it's very easy too: (I put the example whit Boxcoll, It's too much faster than Sprcoll, but the proccess it's basically the same)
If Boxcoll (spr_Object_01 , pos_X , pos_Y ,_
spr_player_Shot , shot_X , shot_Y)
//Get the position on collide the shot
pos_get_X =shot_X
pos_get_X =shot_X
//Get the position on collide the shot
pos_get_X =pos_X
pos_get_X =pos_X
endif
Have in mind, if you use Sprcoll, you can take exactly the part of the surface on collide in this examples the bullets, imagine a Robot, then you can find whit this same code but whit SPRCOLL, the shape of this Graphics... Whit boxcoll, you only search the box around this Sprite... but too much rapid in the internal calculations...
PS: IF you want put this 2 Questions in another part in the forum... here it's a bit hide... and perhaps for search another time it's a bit confusing... or for some one come new to the Community...
I hope I can help you.
i tried that
Quote from: MrTAToad on 2012-Dec-19
IF OPENFILE(1,"test.dat",1)
READLONG 1,variable1
CLOSEFILE 1
IF variable1<variable2
IF OPENFILE(1,"test.dat",0)
WRITELONG 1,variable2
CLOSEFILE 1
ENDIF
ENDIF
ENDIF
but it seems to crash after opening app... and if i have blank "highscore.txt" too :(
already tried with SHORTIEE,IEEE,ULONG,WORD,UWORD
the one who was looking better was ULONG
Yes, it will do if the file is empty - it would be better to use INI files
You have to test against fileeof or whatever the command was.