Text stops updating [solved]

J

JD9999

Guest
I have a project for school due Tuesday and have just run into a massive problem.
I have a script that handles another script. The script draws text on the screen every interval, specified by the first thread (30 steps for each second, the default room speed). It does this by drawing the text, sleeping for the interval, and then clearing the screen with black before the next call occurs.

The problem is that the sleep is fine (I have debugged the application several times), but the text is not showing on my screen. Though this could be a question of performance (considering the time it takes to load), I think it is an issue that I am unable to work out. The worst part about the problem is it doesn't always occur at the same place, but the time will come when the text will stay on the screen for 30 seconds or something ridiculous and then go straight to the countdown sounds. After this, it won't even switch for the next room.

I have pasted below everything I think needs to be pasted, but if you need anything else please tell me. The room just has the controller_intro_game object.

intro_script_controller - the script called by the controlling object
Code:
if(global.complete == 1){
 exit
}
draw_set_color(c_white)
draw_set_font(intro_font)
helper_script_display_text("Gargarin Day - by Jamie & Bryan Games", 150)
helper_script_display_text("April 12, 1961 - The first man arrived in space", 180)
draw_set_font(ch1_font_info_small)
helper_script_display_text(chr(34) + "Yuri Alekseyevich Gargarin", 180)
helper_script_display_text("is to arrive in space in ETA 1450" + chr(34), 180)
show_debug_message("coming into problem")
helper_script_display_text(chr(34) + "Yuri is in position, detaching 6 shuttles now" + chr(34), 60)
helper_script_display_text(chr(34) + "Wait, WHAT!?" + chr(34), 180)
show_debug_message("intent is to wait")
sound_play(intro_sound_rocketship_takeoff)
global.complete = 1

helper_script_display_text
- the main engine room of the introduction. Called by the first script.
Code:
draw_text(32, 192, argument0)
sleep(argument1 * 1000 / 30)
draw_clear(c_black)
/*
draw_text(32, 192, "")
sleep(1000)
*/
controller_intro_gameStarter - the sole object in the intro room. In the format of information so I don't have to post three pictures
Code:
Information about object: controller_intro_gameStarter
Sprite: 
Solid: false
Visible: true
Depth: 0
Persistent: false
Parent: 
Mask: 
Create Event:
set variable room_speed to 30
set variable global.complete to 0
Alarm Event for alarm 0:
go to next room with transition effect
Draw Event:
execute script intro_script_controller with arguments (0,0,0,0,0)
set Alarm 0 to 240
If you need anything else please let me know
Thanks in advance!
 

The-any-Key

Member
Thats no surprise.

Calling draw_text only draw the text to the application surface.
The application surface is drawn when each step has ended.

So you actually:
draw_text(32, 192, argument0)
draw the text to the application surface
sleep(argument1 * 1000 / 30)
Wait
draw_clear(c_black)
Clear the application surface

You need to wait for the step to end to see the application surface. You can setup alarms to do what you want. And draw a variable like:
create event:
Code:
MyTextToDraw="";
alarm[0]=room_speed*1;
alarm[1]=room_speed*10; // wait 10 seconds before set next text
in the draw event:
Code:
draw_text(0,0,MyTextToDraw)
And then in each alarm set:
alarm[0] event
Code:
MyTextToDraw="My text"
And in another alarm
alarm[1] event
Code:
MyTextToDraw="Other text"
This is just a simple way. You can use a array and a counter variable instead to optimize it.
 
Last edited:
J

JD9999

Guest
It worked! Thanks so much :)
 
Last edited by a moderator:
Top