Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

SpazBoy_the_Mitey

Just a few billion questions

This topic is 6549 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hiya guys, I had a bit of a programming session this morning (rare pleasure these days) and I have just a few questions... I am writing a 2d sprite based game and I was wondering this: Would there be any difference in speed/memory used if my sprites were done like this... class SpriteClass { GroovyGraficalClass TheArtIsInHere; int XPos,Ypos; void LoaditFromFile(); void DrawItSomewhere(); //etc... }; And then put into something like a linked list, or what if it were this: class SpriteClass { GroovyGraficalClass TheArtIsInHere; int XPos,Ypos; }; and the list had the functions for loading etc. but to operate on the Current item in the list? (of course in the real thing I''ll load my grafx into a lookup table and reference that in the class for memory''s sake) Also, if I wanted my game (it''s 2d, ddraw) to be resolution independant, is it fast enough to refer to my screen with floats (ie: 0.0 = left, 0.5 = middle, 1.0 = right, then multiply by resolution) or is there a faster way? I used this method when I was writing a little asteroids clone, because I was writing the game code in turbo C++ ver 3, in 320x200, 256 colour (greyscale) while my friend was finishing up our little grafx engine for direct-x. It seemed okay in that case, but a few little lines zooming around the screen isn''t exactly processor intensive stuff. Also, I just recently moved out of home (hooray). I found out the hard way that you can''t live on instant noodles and pizza and was wondering if anyone had some good recipes? And (I wrote this post over about half an hour by the way...) how does inheritance work in c++? If I make my sprite class, can I make a ''baddie'' class that builds on this? Anyway, I hope some clever individual out there can give me a hand - it would be much appreciated ---------- Disco Love For Everyone

Share this post


Link to post
Share on other sites
Advertisement
Well, from what I gather, calling object.dosomething() will cost you the same as dosomething( &object ), so you could do the class thing and have good speeds. I''m writing a 2d game as well, I dont have a sprite class but I do have an image class. Its got functions to draw lines and such onto itself and copy other images onto itself with alpha transperancy.

I think that floats are now fast enough to be used a lot in code but you generally want to do any precalculations you can to save time and speed things up. I dunno, try using floats for your screen positions and compare that with fixed point math.

Inheritance is fun, you might want to search for some c++ documentation on that, i found an html book on the web, it talks about differences between c and c++. You could use inheritence in this case to make the baddies from sprite class, you will have to read the help to get the syntax and try it out on a console app till you get the hang of it.

Fried beef patties ( or something that resembles them ):
Take ~250g ground beef, add 1 chopped onion, 1 egg (raw no shells), add 1 to 2 slices of dried bread that has been soaked till moist again (or use normal bread and put it in water till mosit) note bread should be wringed out some you just want it pasty not dripping, add pepper, salt, soya sauce and magi to taste. mix this with your bare hands till its all mixed, form into patties aobut 2.5" by 1 think, cover in bread crumbs and fry on an oiled frying pan till brown and meat cooked, get some taters with that and youve got yourself a meal. I think...

OneEyeLessThanNone

incoherent bable will frighten adults and attract children

Share this post


Link to post
Share on other sites
hmm, food sounds nice right about now.

I''ve been playing around with my code again, and
now I think I might just go in plain vanilla c/ asm.

I''m more comfortable with these and my c code always
turns out to be more flexible than my oop stuff.

I dunno, maybe I''m just old fashioned


----------
Disco Love For Everyone

Share this post


Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!