Raw draw help?

Started by Squinky, Mon 17/11/2003 22:05:04

Previous topic - Next topic

Squinky

Okay, I'm trying to make a little rawdrawn bar that goes from one point to the other based upon globalint (5). But All I get is a line drawn across the are I want, when it resets, it just stays that same old line....

So I guess my question is:
How do I "erase" a rawdrawn line once it is drawn?

player enters room before fade in code
RawSaveScreen ();
Rep execute

if (GetGlobalInt (5)>0){
 RawSetColor (10);
RawDrawRectangle (40,20,GetGlobalInt (5),20);
}

if (GetGlobalInt (5)==0){
 RawRestoreScreen();
 }

while (GetGlobalInt (5)<100) {

number++;

if (number>=100){
SetGlobalInt (5,GetGlobalInt (5)+1);

 if (GetGlobalInt (5)>=100){
 SetGlobalInt (5,100);
 number=0;
 
}
}
}

Pumaman

QuoteRawDrawRectangle (40,20,GetGlobalInt (5), 20);

You've specified the same Y co-ordinate for the top and bottom of the rectangle, thus you just get a line.

Change the second "20" to "30" or however tall you want the bar to be.

Squinky

Hey thanks CJ, that does make it look a little nicer.....

I'm thinking that my raw draw script is working, it's just that the counter it's tied to is moving to fast....And for the life of me I can't slow it down...

I used int number to try and slow it down...but no...

The code
while (GetGlobalInt (5)<100) {

number++;

if (number>=100){
SetGlobalInt (5,GetGlobalInt (5)+1);

if (GetGlobalInt (5)>=100){
SetGlobalInt (5,100);
number=0;

}
}
}  

anyone?


Gilbert

Because you didn't add a Wait() in the while loop, thus the while loop would be executed in one single game loop. So:
while (GetGlobalInt (5)<100) {
number++;
Wait(1);
if (number>=100){
SetGlobalInt (5,GetGlobalInt (5)+1);
if (GetGlobalInt (5)>=100){
SetGlobalInt (5,100);
number=0;
}
}
}

However, as that Wait() paused your game, if that's not what you want, just remove the while part:

//while (GetGlobalInt (5)<100) {
number++;
if (number>=100){
SetGlobalInt (5,GetGlobalInt (5)+1);
if (GetGlobalInt (5)>=100){
SetGlobalInt (5,100);
number=0;
}
}
//}

Squinky

#4
Whelp, I think I'm heading down the right track now....but heres the deal, I prefer the one without the wait....but both of those cause the game to run really slow. Like nearly frozen slow....but only for about a minute and then the raw draw thingy starts moving across the screen and it's all good....

---Edit--------------
And again, thank you Gil. I'm gonna have to send you a fruit cake or something...heh

Gilbert

Slow before the rawdrawing? I know the reason, that's because GlobalInt(5) becomes zero for 100 loops (since number increments from 0 to 100 for GlobalInt(5) to increment 1), and whenever GlobalInt(5)==0 in a game loop currently, RawRestoreStoreScreen() would be executed, which can be slow as it's now executed for 100 times in a row. To fix this, you may change (find in your original codes):

if (GetGlobalInt (5)==0){
RawRestoreScreen();
}

to:

if ((GetGlobalInt (5)==0)&&(number==0)){
RawRestoreScreen();
}

CB..

ive been using the timer functions a lot in repeatedly execute to create events thats i want up-dated or repeated only every few seconds or so

and settings a timer in enters room
SetTimer(6,200);

then
in the repeat ex

if (IsTimerExpired(6)==1)
{if ((character.y>70 && character.y<90))
{DisplaySpeechBackground (EGO, "Periscope Depth");}
else if ((character.y>90 && character.y<110))
{DisplaySpeechBackground (EGO, "Depth 50 Metres");}
else if ((character.y>110 && character.y<130))
{DisplaySpeechBackground (EGO, "Depth 100 Metres");}
else if ((character.y>130 && character.y<150))
{DisplaySpeechBackground (EGO, "Depth 150 Metres");}
else if ((character.y>150 && character.y<180))
{DisplaySpeechBackground (EGO, "Depth 175 Metres");}
else if ((character.y>180 && character.y<200))
{DisplaySpeechBackground (EGO, "Depth 200 Metres");}
else if ((character.y>200 && character.y<220))
{DisplaySpeechBackground (EGO, "Depth 225 Metres");}
else {DisplaySpeechBackground (EGO, "were too deep!");}
SetTimer(6,1000);}


this one tells me my current position on the screen evry ten seconds;

(im a submarine so it tells me my depth)
im hoping this saves a lot of processing going on as well?
(as it only runs the code if the timer expires or does it read the code still but only execute it if the timers expired)
anyhuw i still havent grasped the basics of setting my own variables etc so this is how im getting things done..

Gilbert

I think it won't use much processing power, as the codes shouldn't be executed if the timer's not expired.

By the way did you set the game to run at 100FPS? (as you set the timer to 1000 game loops and you mentioned ten seconds) In that case, you may need to  consider whether people playing your games have computers fast enough to handle that high frame rate.

CB..

Cheers Gilbot,
i was hoping that would be the case as most everything im doing seems to need to be in repeatedly execute to work ...sorry about the ten seconds thing , i posted an older version of the code by mistake .  

SMF spam blocked by CleanTalk