Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Matrix Flickering

Author
Message
Parapsycho
18
Years of Service
User Offline
Joined: 15th Nov 2006
Location:
Posted: 4th Dec 2006 09:23
I'm working on a driving game, and every time I run the program the matrix starts flickering.

I searched the forum and found this thread: http://forum.thegamecreators.com/?m=forum_view&t=16707&b=3
but none of that seems relevent to my program, except for maybe the clearing the screen part. I've tried using the CLS command at various areas in the code, but it didnt help at all.

Here is my code so far:
indi
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 4th Dec 2006 09:55 Edited at: 4th Dec 2006 09:55
try updating the matrix with update matrix NUM before use in your main loop.

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 4th Dec 2006 13:48
@Parapsycho

This is one of those problems that can trick you! The problem really isn't matrix flicker per se. I ran the code and noticed that your object was shifting back and forth and the camera was following it. It gives the appearance of flicker or a screen refresh problem.

You might kick yourself when I tell you the solution.

In this section of code:



Position object 10,newposx#,posy#+20,newposz# is in the wrong place. This way, you end up positioning the object with values that haven't been calculated yet - because the newvalues are based on the objects position. You have to position the object first, then get the set of new values relative to it's position. So the code should look like:



All you have to do was put Position object 10,newposx#,posy#+20,newposz# above posx# . This was a sneaky problem!

Enjoy your day.
Parapsycho
18
Years of Service
User Offline
Joined: 15th Nov 2006
Location:
Posted: 4th Dec 2006 19:55
Wow!
That was easy. Thanks!

I am kicking myself for not catching that. I'm still learning to visualize the processes that the program goes through to give the output. Any ideas to help that, or does it just come with experience?

When I was taking a (really basic) C++ class, we made flow charts to map out how our program works, but I guess when the program gets to hundreds of lines, that's kind of hard to do.
Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 5th Dec 2006 04:16
The flow chart is still an excellent idea no matter how big the program is. The flow chart doesn't map each individual line, but should track the events from start to finish to help you structure your program. A flow chart or visual aid should be one of the first things you do. It can save a lot of headaches later! As the program grows, you can modify your flow chart, change ideas, whatever. The whole thing is that organization will REALLY help one's program development. And having a plan and structure ahead of time is a real time saver.

In my opinion, a visual aid is priceless, so don't abandon the idea of creating a flow chart.

Everybody's program is going to have bugs, but if one's program is organized and sectioned into nice digestible chunks, it becomes a little easier to track down problems. Your example was small enough so tracking down the problem wasn't too hard. I suspected the way the screen was jumping that it had something to do with either camera position or object tracking since there wasn't any matrix altering code inside your loop. I think the small amount of experience I have helped me track it down quickly.

One method you can try when debugging your code is just to comment out suspect lines of code until the bad behavior disappears. This can help you track down where the problem lies, of course this shuts down other functions, but the key is to at least have an understanding of what section of code controls what, so when you comment something out you're at least 80 percent sure it won't blow up your computer!

Enjoy your day.

Login to post a reply

Server time is: 2025-05-26 05:46:02
Your offset time is: 2025-05-26 05:46:02