Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, Nymphodora, VoroneTZ), 1,485 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
firatv, wandaluciaia, Mega_Rod, EternallyCurious, howardR
19050 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
jerky movement, cant see why #367225
04/10/11 22:33
04/10/11 22:33
Joined: Mar 2011
Posts: 11
R
RetroGamer Offline OP
Newbie
RetroGamer  Offline OP
Newbie
R

Joined: Mar 2011
Posts: 11
i had most of my temp(learning) code then i noticed theres a jerk every second it seems.. has to be a misplaced wait.. or im using it wrong.. i removed everything to find where its at. im left with about 20 lines of code. but havent located my mistake.

heres the code.....
Code:
#define move_speed skill1
VECTOR move_vec;

function update_movement()
{
   move_vec.x = key_force.y * (time_step * my.move_speed);
   move_vec.y = -key_force.x * (time_step * my.move_speed);
}

//uses: move_speed
action player_move()
{
   player = me;
   //my.temptilt = 0;
   c_setminmax(my);
   camera.genius = player;
   vec_for_min(feet_bottom,me);
   while(me != NULL)
   {
      //update_gravity();
	update_movement();
      //handle_jumping();
	c_move(my,move_vec,fall_dist,GLIDE);
      //update_camera();
	wait(1);
   }
}



somewhere is a problem has to be simple but i just dont see it.
here is my main function..

Code:
void main()
{
   time_smooth = 0.666;
   video_mode = 9;
 //video_screen = 1;
   level_load ("******.WMB");
   wait(2);	
}



i tried time_smooth thinking time_step was changing... no difference.

can anyone please point out my mistake(s).

could it be in my c_move? seems if i add gravity the jerkiness is real noticable

heres my gravity piece (still jerky w/o it)

Code:
function update_gravity()
{
   ground_dist = c_trace(my.x,vector(my.x, my.y, my.z -1000),USE_BOX)-feet_bottom;
   if(ground_dist > 0)
   {
      fall_dist.z = -30 * time_step;
   }
}



Thanks in advance.
i appreciate all the assistance, sorry to bring noob problems to the table. but i cant make the bed if i dont unfold the sheet first,lol


ever hear the expression once you learn it's hard to forget...
I think learning programming languages as,

I just mastered old school roller skating...
Now they have roller blades, Same wheels, different setup
Re: jerky movement, cant see why [Re: RetroGamer] #367227
04/10/11 23:57
04/10/11 23:57
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
You don't bring any noob problems to the table. You've got a problem and are asking for help here. That is exactly what this forum is meant for.

The code you show us here looks solid on a first sight. If the jerk appears about every second it is very unlikely that the error is to be found in the code you posted here. So I see basically two options in this case:

1. There is a jerk because of a sudden framerate drop. time_smooth will work against this issue, but it's not capable of miracles. You can check if this is the case by bringing up the debug panel (F11) and looking at the the framerate. If the framerate drops about every second you know that you do something very costly (in terms of cpu cycles) at a place in your code. It's even possible that your computer does something time intensice every second. However, if you can watch a framerate drop you can be sure you have a performance problem and the jerks are only symptoms of your problem.

2. You change move_vec or fall_dist somewhere else in your code but only every second. Check your code for a loop where there is a wait(-1) or a wait(64) or a simliar large value in a wait. If you manag to find such a loop the error is likely to be in this loop.


Always learn from history, to be sure you make the same mistakes again...
Re: jerky movement, cant see why [Re: RetroGamer] #367228
04/11/11 00:28
04/11/11 00:28
Joined: Mar 2011
Posts: 11
R
RetroGamer Offline OP
Newbie
RetroGamer  Offline OP
Newbie
R

Joined: Mar 2011
Posts: 11
thank you for the fast reply Uhrwerk.
i was afriad of that reply... here's why.

1. there is only the one while and wait.
2. i did use the f11 key... and yes fps went from 81ish to 170 every second. (even with max_fps. the frame rate was unsteady)
3. i didnt think the code was the real culprit

i think my video card itself is bad, ive tried to play certain other games and the one sec lag was there, tho i never connected the 2 problems together.
i was so hoping that it wasnt hardware... would then be easier to fix.

now that makes me wonder how many issues i had earlier that wasnt a coding issue. *fist pounds keyboard*lol

Again this forum has helped me yet again. Thanks

btw its a old cheap nvidia geforce 8400gs frown.
had a ati hd pro (forgot the series) but burnt it out of course gaming,lol

Last edited by RetroGamer; 04/11/11 00:33.

ever hear the expression once you learn it's hard to forget...
I think learning programming languages as,

I just mastered old school roller skating...
Now they have roller blades, Same wheels, different setup
Re: jerky movement, cant see why [Re: RetroGamer] #367229
04/11/11 02:14
04/11/11 02:14
Joined: Jan 2002
Posts: 4,225
Germany / Essen
Uhrwerk Offline
Expert
Uhrwerk  Offline
Expert

Joined: Jan 2002
Posts: 4,225
Germany / Essen
I've never heard of a video card before, that creates a frame rate drop every second. That does not make sense to me. If there is a hardware failure I'd expect a total fail under normal circumstances. However, I've got only limited experience with hardware issues and wouldn't exclude that either. But maybe it's worth checking the taskmanager. Is there any program that creates workload every second?


Always learn from history, to be sure you make the same mistakes again...
Re: jerky movement, cant see why [Re: RetroGamer] #367230
04/11/11 02:33
04/11/11 02:33
Joined: Mar 2011
Posts: 11
R
RetroGamer Offline OP
Newbie
RetroGamer  Offline OP
Newbie
R

Joined: Mar 2011
Posts: 11
i ran a few of the pre coded player scripts from AUM with my prebuild room and block to test movement and gravity

no weird pause, smooth as could be..
my card is a piece of junk but its not fault....

i have probably 110 lines of code in 3 scripts total... very basic
im trying to make my own templates so i try to seperate things to be able to improve and add to them.
i did copy some of other peoples code, because i could understand it and change it how i liked. which is how ive been learning

before i scrap and redo them, i would like to be a little desciption of how i got my scripts and ill post em.

the level is just a big hollow block with a small block inside
it for the player to fall off (cbabe,mdl).(doubt its level issue)
i commented most of player.c out to eliminate possiblities

first is my main file which resides with compiled level
and defines the file that locates resources
main.c
Code:
/////////////////////////////////////////////////////
////  Default Gamestudio Key and Debug functions  ///
//// ToDo:  Replace with Personalized functions  ////
#include <default.c>;

/////////////////////////////////////////////////////
////  Personal Resource file Locations   ////////////
#include "Resources\Includes\resources.h";

/////////////////////////////////////////////////////
////  Included Scripts   ////////////////////////////
#include "Resources\Scripts\Player.c";

////////////////////////////////////////////////////
////   Main Starting Function   ////////////////////
void main()
{
   time_smooth = 0.666;
// video_set(sys_metrics(0), sys_metrics(1), 32, 1); // detect and use the best screen resolution
   video_mode = 9;
// video_screen = 1;
   level_load ("newshit.WMB");
   wait(2);	
}



which calls my 2nd file that defines paths resources.h
Code:
/////////////////////////////////////////////////////////////////////
//// Main resource locations and files   ////////////////////////////

#define PRAGMA_PATH "Resources\Entities";
#define PRAGMA_PATH "Resources\Sounds";
#define PRAGMA_PATH "Resources\Textures";
#define PRAGMA_PATH "Resources\Scripts";



then finally the movement code i have

player.c
Code:
//////////////////////////////////////////////////////////////////////
//  Player movement and interaction  /////////////////////////////////
//////////////////////////////////////////////////////////////////////
#define move_speed skill1
#define turn_speed skill2

//////////////////////////////////////////////////////////////////////
//  Player_move defines  /////////////////////////////////////////////

VECTOR move_vec; // player movement forces
VECTOR fall_dist; 

//////////////////////////////////////////////////////////////////////
//  Gravity related defines  /////////////////////////////////////////////
var ground_dist;
var feet_bottom; 

//////////////////////////////////////////////////////////////////////
//  Camera variables  ///////////////////////////////////////////
var temptilt; // camera tilt angle
var eye_height = 30; 

//////////////////////////////////////////////////////////////////////
//  Gravity  /////////////////////////////////////////////////////////
function update_gravity()
{
    ground_dist = c_trace(my.x,vector(my.x, my.y, my.z -1000),USE_BOX)-feet_bottom;
    if(ground_dist > 0)
    {
	fall_dist.z = -30 * time_step;
    }
}

//////////////////////////////////////////////////////////////////////
//   Jumping function    /////////////////////////////////////////////

function handle_jumping ()
{
   wait(1);
}

//////////////////////////////////////////////////////////////////////
//   Movement function    ////////////////////////////////////////////

function update_movement()
{
    move_vec.x = key_force.y * (time_step * my.move_speed); 
    move_vec.y = -key_force.x * (time_step * my.move_speed);
}


//////////////////////////////////////////////////////////////////////
//  Camera function  /////////////////////////////////////////////////

function update_camera()
{	
    vec_set(camera.x,vector(-100,0,20)); // to see what player is doing
//  vec_set(camera.x,player.x); // go back to first person
    camera.z += eye_height;
    camera.pan = player.pan;
    temptilt += (mouse_force.y * 3) * 4 * time_step;
    my.pan -= (mouse_force.x * 8) * time_step;
    camera.tilt = 0 + temptilt;
    temptilt = clamp(temptilt,-75,75);	
}


//////////////////////////////////////////////////////////////////////
//  Main player action  //////////////////////////////////////////////

//uses: move_speed
action player_move()
{
    player = me;
  //my.temptilt = 0;
    c_setminmax(my);
    camera.genius = player;
    vec_for_min(feet_bottom,me);
    while(me != NULL)
    {
//	update_gravity();
	update_movement();
//	handle_jumping();
	c_move(my,move_vec,fall_dist,GLIDE);
//	update_camera();
	wait(1);
    }
}



remember not using the commented out to eliminate possibilities.
hopefully that might help... ive reinstalled both windows and GS hoping it was some corrupted file. to no avail.
so since i know its not hardware. it must be some hiding bug or something im doing... mebbe like including the player.c twice. once in main.c then in resources? perhaps how they call the script? should i try to put my main startup function in the player.c script, which makes it the main and only script really needed eliminating other script?
i think its something in player.c ive been messing with that one only, i must have changed or did something. or at least i didnt notice it till i started adding more code

i would like to thank the community for the good help i recieved thus far laugh
any more input or assistance would be most appreciated, please

Thank You

video card... the pc's gpu nvidia 8400gs

Last edited by RetroGamer; 04/11/11 02:36.

ever hear the expression once you learn it's hard to forget...
I think learning programming languages as,

I just mastered old school roller skating...
Now they have roller blades, Same wheels, different setup
Re: jerky movement, cant see why [Re: RetroGamer] #367234
04/11/11 03:38
04/11/11 03:38
Joined: Mar 2011
Posts: 11
R
RetroGamer Offline OP
Newbie
RetroGamer  Offline OP
Newbie
R

Joined: Mar 2011
Posts: 11
also under f11 debug..
these are the values that changed constantly

fps 50 - 186
pps 105k - 210k+?? polygons doubleing... sounds strange?

pan 1 -4 *time for panels, texts and screen entities rendering (and for the 3D card to flush its command buffer)
ref .9 - 9.9 *time for screen refresh, monitor sync, and fps_max idling*

only 2 functions running
the memory doesnt increase per sec.. doesnt change
no extra background tasks going
mebbe that will help more


ever hear the expression once you learn it's hard to forget...
I think learning programming languages as,

I just mastered old school roller skating...
Now they have roller blades, Same wheels, different setup
Re: jerky movement, cant see why [Re: RetroGamer] #367470
04/13/11 20:06
04/13/11 20:06
Joined: Jun 2005
Posts: 656
G
Grafton Offline
User
Grafton  Offline
User
G

Joined: Jun 2005
Posts: 656
Try limiting the frame rate to 60.


Not two, not one.
Re: jerky movement, cant see why [Re: RetroGamer] #367650
04/16/11 05:43
04/16/11 05:43
Joined: Mar 2011
Posts: 11
R
RetroGamer Offline OP
Newbie
RetroGamer  Offline OP
Newbie
R

Joined: Mar 2011
Posts: 11
i have tried that
min_fps = 60
max_fps = 60

is it standard to do that (locking framerate to some extend).
i still dont see why the framerate would jump around otherwise.


ever hear the expression once you learn it's hard to forget...
I think learning programming languages as,

I just mastered old school roller skating...
Now they have roller blades, Same wheels, different setup
Re: jerky movement, cant see why [Re: RetroGamer] #367677
04/16/11 13:30
04/16/11 13:30
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Don't set fps_min, only fps_max.


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1