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

Username:   Password: 
 RegisterRegister   
 Game visuals glitching out.
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Cosolix




PostPosted: Wed Jan 17, 2018 6:01 pm   Post subject: Game visuals glitching out.

What is it you are trying to achieve?
Turing fighting game.


What is the problem you are having?
The visuals are glitching out


Describe what you have tried to solve this problem
I have already used setscreen and view.update

Code is attached


Please specify what version of Turing you are using
4.1



Fighting.zip
 Description:

Download
 Filename:  Fighting.zip
 Filesize:  123.23 KB
 Downloaded:  97 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
TokenHerbz




PostPosted: Thu Jan 18, 2018 5:07 am   Post subject: RE:Game visuals glitching out.

I can see that you put alot of house into this, so i'll give my constructive feedback.

Your most likely going to be better off rewriting this program, the endless amount of copy paste already poses the tedious task of isolating the issue, but not only that the structure is not good..

--------So I took 10 mins to write you this DEMO -----

Please copy paste it into your turing and BE SURE you read all the COMMENTS before you run the program and try it out.

You'll notice that for the entire game i'm only drawing and refreshing once, compared to the 120 times you are doing it, which I feel is the issue of your flickering.


BEST OF LUCK my man, Heres the DEMO... enjoy!

Turing:

%%forking and process are bad
%% use a structured setup like this

%%Game Var Init
%%Game Controls
%%Game Var Adjustments
%%Game Display
%%Game Recycle

%%forks and process never run how you want them to, and
%% even just browsing through your code you have so many displaying things
%% AND redrawing so thats probably why your games glitching out...

%%Example of how you should try to recode it..


setscreen("Graphics:600;600")

%%player vars
var p1x,p1y,p1s,p1sp : int
var p2x,p2y,p2s,p2sp : int
var p1c, p2c : int %% color chart here -> http://compsci.ca/v3/viewtopic.php?t=3782

%%Procedure, NOT proccess
%%make each 1 one goal to simplify life
proc initPlayers
    p1x := 200 %%player 1 init
    p1y := 200
    p1s := 10
    p1sp := 4
    p1c := 40
    p2x := 300 p2y := 200 p2s := 10 p2sp := 4  p2c := 55 %%player 2 init can do like this to 
end initPlayers

%%hardcoded stage, since its demo
proc drawStage
    drawfillbox(100,100,maxx-100,120,7)
end drawStage

%%drawing multiple players
proc drawPlayers
    drawfillbox(p1x,p1y,p1x+p1s,p1y+p1s,p1c)
    drawfillbox(p2x,p2y,p2x+p2s,p2y+p2s,p2c)
end drawPlayers

%%moving player 1, can make it all players, its for demo so small
proc movePlayer1 ( chars_ : array char of boolean )
    if chars_('w') then %%UP
        p1y += p1sp
    end if
    if chars_('s') then %%DOWN
        p1y -= p1sp
    end if
end movePlayer1

%%here to make player 2 to show your FORK proccess MIMIC
%% and to show you hopefully that its possible to do without FORK/PROCESS
proc movePlayer2( chars_ : array char of boolean )
    if chars_(KEY_UP_ARROW) then %%UP
        p2y += p2sp
    end if
    if chars_(KEY_DOWN_ARROW) then %%DOWN
        p2y -= p2sp
    end if
end movePlayer2

%%example of collision logic, remember you can cram all players/objects
%% as the procedure handles that one task, controling boundries,
%% just a little code for the demo for you, keeps player one on floor/roof
proc boundries
    %%only coding for down collision, you can add for all sides, etc.
    if p1y + p1sp <= 120 then
        p1y := 120 %% i suggest having variables for stages also,
                    %% so its easier to update if you want the platform
                    %% to start moving for example, hardcoded VARIABLES are
                    %% usually BAD In my opinion, unless its CONST
    end if
    if p1y+p1s >= maxy then  %%roof barrier
        p1y := maxy - p1s
    end if
end boundries

%%%%%%%%%%%%%%     N O T E   %%%%%%%%%%%%%%%%%
%%If you went ahead and created CLASSES you could avoid
%% copy pasting and just pass the array of objects to the proc
%% saving alot of time, for a future thought aswell, makes it much cleaner
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

initPlayers  %%GAME INIT
var chars : array char of boolean
loop    %%MAIN GAME LOOP
   
    %%PLAYER INPUT/CONTROL
    Input.KeyDown(chars)
    movePlayer1(chars)  %%w/s moves red up/down
    movePlayer2(chars)   %% up arrow/ down arrow moves blue (they both CAN move at the SAME time)
   
    %%GAME LOGIC/HANDLING
    boundries
   
    %%DRAW PHASE
    drawStage
    drawPlayers
    View.Update
    delay(20)
    cls
   
    %%EXIT GAME
    exit when chars('q')
end loop

put "ENJOY THE DEMO / hope you feel the need to refine your game now!"
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  [ 2 Posts ]
Jump to:   


Style:  
Search: