Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Flashiness during a process, more complicated than it sounds
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
GOLDEN WEAPON




PostPosted: Tue Jun 10, 2003 6:54 pm   Post subject: Flashiness during a process, more complicated than it sounds

Ok in my game, there is a process for drawing and moving the enemies. The problem is that it doesn't run in time with my drawscreen (which draws the background, jets, stats, etc.), that has the View.Update in it. In the for loop that draws the enemies, it draws some of them, then the drawscreen procedure does View.Update and not all of them show up, this creates an overall flashy effect. Is there anyway to time the View.Updates in the drawscreen to it only View.Updates after all the enemies on the screen are drawn or something that would have that effect? Game attached.


TheGame.zip
 Description:

Download
 Filename:  TheGame.zip
 Filesize:  304.2 KB
 Downloaded:  316 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Tue Jun 10, 2003 7:06 pm   Post subject: (No subject)

well first you have to set the screen to offscreenonly
View.Set("offscreenonly")
then you can View.Update
what View.Update basicly does is that it takes everything on the offscreen and dumps it on to the viewable screen, and inorder to do that you have to set it to offscreenonly
if you want the thing to not flash, draw the background, then draw ur moving objects, then View.Update
Andy




PostPosted: Tue Jun 10, 2003 7:09 pm   Post subject: (No subject)

and see homer, i do help... Very Happy
and naoki, i dun spam all the time, unlike u
Mazer




PostPosted: Tue Jun 10, 2003 7:10 pm   Post subject: (No subject)

"more complicated than it sounds"?

Laughing not at all my fine feathered friend, not at all. you'll see. i'm gonna post a tutorial later, makes drawing with process much better.
Andy




PostPosted: Tue Jun 10, 2003 7:30 pm   Post subject: (No subject)

hey nick, what did u get on ur game?
Mazer




PostPosted: Tue Jun 10, 2003 7:55 pm   Post subject: (No subject)

i don't know yet! why do people keep asking me?! Laughing

actually, i have to wait until he reads the documentation and stuff before i can get a mark. normally he's supposed to read that before the interview but i wanted to do my interview during class so he said we should have it a few minutes later. i'll probably know tomorrow
Tony




PostPosted: Tue Jun 10, 2003 8:04 pm   Post subject: (No subject)

whats the point of drawing in a process? I mean, since View.Update is located in another procedure, it would have to wait untill process has finished... that just complicates things a lot more, and you dont gain anything from using it, over single/multiple procedures.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
GOLDEN WEAPON




PostPosted: Tue Jun 10, 2003 8:21 pm   Post subject: (No subject)

Tony is the only one that will probably make it work. DT, I know about offscreenonly and View.Update and that shit, my problem was that in the process that the enemies were drawn in, it would draw the first few out of nine, then in the drawscreen procedure that was running at the same time, it would View.Update and only some of the enemies would be shown becuase only a few were drawn! So I have to put it in my drawscren procedure! So simple now lol. Is anyone going to that video game programming camp?
Sponsor
Sponsor
Sponsor
sponsor
GOLDEN WEAPON




PostPosted: Tue Jun 10, 2003 8:44 pm   Post subject: (No subject)

Actually, that didn't work either. DAMMIT!!!!!!! Argh, needed to get that out... Ok here are the chunks of code that apply to this,

code:

%Declaring the enemy pictures
var enemies : array 1 .. 100 of int
for d : 1 .. 25
    enemies (d) := Pic.FileNew ("ufoshocker.bmp")
end for
for f : 26 .. 50
    enemies (f) := Pic.FileNew ("ufolightfighter.bmp")
end for
for g : 51 .. 75
    enemies (g) := Pic.FileNew ("ufoheavyfighter.bmp")
end for
for h : 76 .. 100
    enemies (h) := Pic.FileNew ("ufobomber.bmp")
end for


var enemyx : array 1 .. 100 of int
for cv : 1 .. 100
    enemyx (cv) := 800
end for

var enemyy : array 1 .. 100 of int
for rv : 1 .. 92 by 9
    enemyy (rv) := 10
end for
for ev : 2 .. 93 by 9
    enemyy (ev) := 60
end for
for wv : 3 .. 94 by 9
    enemyy (wv) := 110
end for
for tv : 4 .. 95 by 9
    enemyy (tv) := 160
end for
for iv : 5 .. 96 by 9
    enemyy (iv) := 210
end for
for iv : 6 .. 97 by 9
    enemyy (iv) := 260
end for
for iv : 7 .. 98 by 9
    enemyy (iv) := 310
end for
for iv : 8 .. 99 by 9
    enemyy (iv) := 360
end for
for iv : 9 .. 100 by 9
    enemyy (iv) := 410
end for

% The Background
procedure drawscreen
    skyx := skyx - 20
    skyxedge := skyxedge - 20
    skyxedge2 := skyxedge2 - 20
    skyxedge3 := skyxedge3 - 20
    if skyx < -640 then
        skyx := 1900
    end if
    if skyxedge < -640 then
        skyxedge := 1900
    end if
    if skyxedge2 < -640 then
        skyxedge2 := 1900
    end if
    if skyxedge3 < -640 then
        skyxedge3 := 1900
    end if
    cls
    View.Set ("offscreenonly")
    Pic.Draw (Clouds, skyx, skyy, picCopy)
    Pic.Draw (Clouds2, skyxedge, skyy, picCopy)
    Pic.Draw (Clouds3, skyx, skyyedge, picCopy)
    Pic.Draw (Clouds4, skyxedge, skyyedge, picCopy)
    Pic.Draw (Clouds5, skyxedge2, skyyedge, picCopy)
    Pic.Draw (Clouds6, skyxedge2, skyy, picCopy)
    Pic.Draw (Clouds7, skyxedge3, skyy, picCopy)
    Pic.Draw (Clouds8, skyxedge3, skyyedge, picCopy)
    locate (1, 1)
    if jethealth1 > 50 then
        colourhealth1 := 10
    elsif jethealth1 > 20 then
        colourhealth1 := 14
    else
        colourhealth1 := 12
    end if
    if jethealth2 > 50 then
        colourhealth2 := 10
    elsif jethealth2 > 20 then
        colourhealth2 := 14
    else
        colourhealth2 := 12
    end if
    put "Player 1:", "" : 2, "Health: " : 20 ..
    put "" : 6, "Lives: ", lives1, " Score: ", score1
    put "Player 2:", "" : 2, "Health: " : 20 ..
    put "" : 6, "Lives: ", lives2, " Score: ", score2
    drawfillbox (145, 520, 145 + jethealth1, 529, colourhealth1) %NOTE: The health bars might not
    drawfillbox (145, 503, 145 + jethealth2, 512, colourhealth2) %be in the exactly right position
    drawbox (145, 520, 145 + jethealth1, 529, 7)                 %due to monitor size differences.
    drawbox (145, 503, 145 + jethealth2, 512, 7)
    if jetalive1 = true then
        Pic.Draw (jet1nofire, x, y, picMerge)
    elsif jetalive1 = false and lastexplosion1 = false and gameoverfinal = false then
        fork explosion1
        fork explosionsound1
    end if
    if jetalive2 = true then
        Pic.Draw (jet2nofire, x2, y2, picMerge)
    elsif jetalive2 = false and lastexplosion2 = false and gameoverfinal = false then
        fork explosion2
        fork explosionsound2
    end if
View.Update
end drawscreen

process enemyprocess
    loop
        delay (2000)
        for r : 1 .. 85
            exit when enemyhigh >= 100
            delay (5)
            for h : enemylow .. enemyhigh
                if enemydead (h) = false then
                    Pic.Draw (enemies (h), enemyx (h), enemyy (h), picMerge)
                    enemyx (h) := enemyx (h) - 10
                    if enemyx (h) = -50 then
                        score1 := score1 - 50
                        score2 := score2 - 50
                    end if
                else
                end if
            end for
        end for
        enemylow := enemylow + 9
        enemyhigh := enemyhigh + 9
        lastattack := timeelapsed
        exit when enemyhigh >= 100
    end loop
end enemyprocess
%Up to now it's all declaration
%this isn't the exact code but it's all you need to know for the main loop

fork enemyprocess %So I call the process before th game starts
loop
     if's and whatnot %The keys and whatnot
    drawscreen %The drawscreen redraws the screen,
                      %when it View.Updates, the process
                      %hasn't finished drawing all the enemies,
                      %so only some are shown, but if I put it
                      %into a procedure, it's in an inf loop and
                      %the game stops running

end loop


Told ya it was more complicated than it seemed...
Tony




PostPosted: Tue Jun 10, 2003 9:54 pm   Post subject: (No subject)

turn the process into a procedure, and so that you dont get stuck with a delay, just use a timer with a flag variable. Keep on calling the procedure up untill the timer reads that w/e time has passed and the rest of procedure can be executed.

Keep in mind that processes DONT run at same time as rest of the program. It fakes multitasking by randomly picking from which procedure to execute the next line. You're better off having a procedure.
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Andy




PostPosted: Wed Jun 11, 2003 3:34 pm   Post subject: (No subject)

cause nick, ur gonna get like 150% on ur game
GOLDEN WEAPON




PostPosted: Wed Jun 11, 2003 3:44 pm   Post subject: (No subject)

ok that's helpful but how do I use a timer?
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 12 Posts ]
Jump to:   


Style:  
Search: