![]() |
|
Can anyone see if im actually coding right. |
dothedru22
Member #7,325
June 2006
|
So awhile back I was looking through the half-life source code and I just sortof figured this is how they do large scale games. So i decided to start programming sortof like that using a lot of pointers and stuff across a lot of files. it just seems like this is the slow way of doig things. like that im not gettting the most fps out of it. I also changed the player structure to have a datafile type already in the structure so i could send the struct to delete the datafile in another function.(sortof hard to explain but you'll see) but since i've done that its made loading the game take 10 times longer. it was instant before to just load the image. now it takes like 10 seconds are so now. so im wondering why this is happening. im also not sure im doing the frame limiting right or if the rest im putting to slow the animation down is the proper way of doing things. thanks a bunch for any help. i know its sortof long. the code is attached to this topic. |
LennyLen
Member #5,313
December 2004
![]() |
Quote: the code is attached to this topic. And so is every other part of your project. If you want people to look at your code (which there's only 10Kb of), you don't need to attach ~700Kb of unnecessary data. I'll paste the relevant part of your code here, so that others don't have to download the entire zip just to see what you are doing... player.h:
player.c:
[edit]Oops, forgot to add the drawing routines: game.c:
|
dothedru22
Member #7,325
June 2006
|
yea. sorry. i did that so people would know how long it took to load. i would have had to post the dat files and stuff anyway if i just gave the .exe to see that. so i just figured i'd do that. but i appreciate you posting it on the forum and stuff. |
A J
Member #3,025
December 2002
![]() |
rest() will pause your program. It is not an effecient way to wait for events to occur. You should be waiting based on a timer variable. ___________________________ |
dothedru22
Member #7,325
June 2006
|
yea i am. i did that fps limiting thats posted on these forums somewhere. im just rying to slow the animtion down. main.c
|
Kitty Cat
Member #2,815
October 2002
![]() |
Your create* functions should allocate (via malloc) the objects, then return a pointer to them, then the destroy* functions should free (via free) them. Having objects on the stack is a bad idea, because there's limited space there. -- |
dothedru22
Member #7,325
June 2006
|
well i've never understood memory mangement that well. like the heap and stack stuff. like if i use malloc to see if theres enough memory to allocate for the structure thats all fine and dandy but what if theres not and it fails. i can't run my game? o well. whatever though i'll use malloc. |
Fladimir da Gorf
Member #1,565
October 2001
![]() |
Quote: using a lot of pointers and stuff across a lot of files. it just seems like this is the slow way of doig things. like that im not gettting the most fps out of it. Well, if you'd do that I bet speed wouldn't be your biggest issue... And the slowdown is caused by the drawing commands. Always. OpenLayer has reached a random SVN version number ;) | Online manual | Installation video!| MSVC projects now possible with cmake | Now alvailable as a Dev-C++ Devpack! (Thanks to Kotori) |
dothedru22
Member #7,325
June 2006
|
well before my player.c looked something like this
and that loaded up fast and stuff. the player.c that was posted before takes about 10 seconds. just wondering why that is. |
|