Forum

Simple Question

Discuss programming topics for the various GPL'd game engine sources.

Moderator: InsideQC Admins

Simple Question

Postby DusterdooSmock » Wed Oct 13, 2010 12:09 am

OK, so i'm new to engine programming, and i want to design a HUD for my mod, even if it won't be functional for the time being.

Can someone please tell me how to draw a picture on-screen?

:P
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Mexicouger » Wed Oct 13, 2010 12:12 am

Open up sbar.c,

Scroll down this this Function:



Code: Select all
/*
===============
Sbar_DrawFace
===============
*/
void Sbar_DrawFace (void)


add a new qpic_t, and don't forget to add the * so it can be used in other functions.(Correct me if I am wrong, That is just something I noticed)

Then scroll down, and right after this:

Code: Select all
if (cl.items & IT_INVULNERABILITY)
   {
        if (kurok)
          Sbar_DrawPic (8, 0, sb_face_invuln);
        else
          Sbar_DrawPic (112, 0, sb_face_invuln);
      return;
   }

    }


Do something like this:

life = Draw_CachePic ("gfx/life.lmp");
M_DrawPic ( (324-life->width)/2, 16, life);

And that draws an image on the screen.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby DusterdooSmock » Wed Oct 13, 2010 12:53 am

OK, so i get this part:

Code: Select all
 
life = Draw_CachePic ("gfx/life.lmp");
M_DrawPic ( (324-life->width)/2, 16, life);


But, what is a "qpic_t" ?

:?:
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Mexicouger » Wed Oct 13, 2010 1:18 am

Look at some of the lines of code that use qpic_t, and connect the dots.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby DusterdooSmock » Wed Oct 13, 2010 1:20 am

Mexicouger wrote:Look at some of the lines of code that use qpic_t, and connect the dots.


OK, will do.

Thanks. ;)
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Spirit » Wed Oct 13, 2010 7:26 am

Please use meaningful titles.
Improve Quaddicted, send me a pull request: https://github.com/SpiritQuaddicted/Quaddicted-reviews
Spirit
 
Posts: 1031
Joined: Sat Nov 20, 2004 9:00 pm

Postby frag.machine » Wed Oct 13, 2010 11:59 am

DusterdooSmock wrote:OK, so i get this part:

Code: Select all
 
life = Draw_CachePic ("gfx/life.lmp");
M_DrawPic ( (324-life->width)/2, 16, life);


But, what is a "qpic_t" ?

:?:


qpic_t is a data structure. In this case, a data structure used to store 2D images.

Looks like you're completely new to any programming, not only engine programming. I'd suggest you to grab a couple of books about programming (data structures and algorithms first, then a good C/C++ book - there are a lot of references around the internet, and even here in other threads) before diving in something so complex as the Quake engine.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby DusterdooSmock » Wed Oct 13, 2010 3:36 pm

frag.machine wrote:
qpic_t is a data structure. In this case, a data structure used to store 2D images.

Looks like you're completely new to any programming, not only engine programming. I'd suggest you to grab a couple of books about programming (data structures and algorithms first, then a good C/C++ book - there are a lot of references around the internet, and even here in other threads) before diving in something so complex as the Quake engine.


Well, i'm a beginner in QuakeC (I understand it a little; enough to do basic stuff), but i figured that i should try some simple stuff in the engine too..
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby frag.machine » Wed Oct 13, 2010 4:18 pm

DusterdooSmock wrote:
frag.machine wrote:
qpic_t is a data structure. In this case, a data structure used to store 2D images.

Looks like you're completely new to any programming, not only engine programming. I'd suggest you to grab a couple of books about programming (data structures and algorithms first, then a good C/C++ book - there are a lot of references around the internet, and even here in other threads) before diving in something so complex as the Quake engine.


Well, i'm a beginner in QuakeC (I understand it a little; enough to do basic stuff), but i figured that i should try some simple stuff in the engine too..


It's okay to do simple tutorials, as long as you have a grasp about what are you doing. That's why I recommend you to read some basic books so you can figure out things like "what's qpic_t" by yourself. Just copy & paste without any idea of what's going on won't teach you much and actually tends to have an opposite effect: in the first failure, you'll very likely get frustrated and give up.
I know FrikaC made a cgi-bin version of the quakec interpreter once and wrote part of his website in QuakeC :) (LordHavoc)
User avatar
frag.machine
 
Posts: 2090
Joined: Sat Nov 25, 2006 1:49 pm

Postby DusterdooSmock » Wed Oct 13, 2010 6:49 pm

frag.machine wrote:
DusterdooSmock wrote:
frag.machine wrote:
qpic_t is a data structure. In this case, a data structure used to store 2D images.

Looks like you're completely new to any programming, not only engine programming. I'd suggest you to grab a couple of books about programming (data structures and algorithms first, then a good C/C++ book - there are a lot of references around the internet, and even here in other threads) before diving in something so complex as the Quake engine.


Well, i'm a beginner in QuakeC (I understand it a little; enough to do basic stuff), but i figured that i should try some simple stuff in the engine too..


It's okay to do simple tutorials, as long as you have a grasp about what are you doing. That's why I recommend you to read some basic books so you can figure out things like "what's qpic_t" by yourself. Just copy & paste without any idea of what's going on won't teach you much and actually tends to have an opposite effect: in the first failure, you'll very likely get frustrated and give up.


Well, i have a few books on c/c++, i've just never finished reading them..
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Downsider » Wed Oct 13, 2010 7:15 pm

I think the Quake engine is a great place to start. It's always good to learn by example, provided you actually learn and don't make a thread/ask questions for every goddamn thing.
User avatar
Downsider
 
Posts: 621
Joined: Tue Sep 16, 2008 1:35 am

Postby Mexicouger » Wed Oct 13, 2010 11:22 pm

I am reading the book called "The C Programming Launguage". It is a very good book, And I feel like I am learning alot. Highly recommend it.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby DusterdooSmock » Fri Oct 15, 2010 5:00 pm

Mexicouger wrote:I am reading the book called "The C Programming Launguage". It is a very good book, And I feel like I am learning alot. Highly recommend it.


Would you mind telling me what store you purchased it at?
:D
DusterdooSmock
 
Posts: 170
Joined: Thu Aug 19, 2010 9:58 pm

Postby Mexicouger » Fri Oct 15, 2010 10:08 pm

DusterdooSmock wrote:
Mexicouger wrote:I am reading the book called "The C Programming Launguage". It is a very good book, And I feel like I am learning alot. Highly recommend it.


Would you mind telling me what store you purchased it at?
:D


I got it on Ebay for like 10 dollars. It is a quality book, However, I can't really do the exercises because I don't know a compiler for it.
User avatar
Mexicouger
 
Posts: 514
Joined: Sat May 01, 2010 10:12 pm

Postby dreadlorde » Sat Oct 16, 2010 12:33 am

Mexicouger wrote:I got it on Ebay for like 10 dollars. It is a quality book, However, I can't really do the exercises because I don't know a compiler for it.
On Windows there's bloodshed devc++. It's an ide with gcc included.
Ken Thompson wrote:One of my most productive days was throwing away 1000 lines of code.

Get off my lawn!
User avatar
dreadlorde
 
Posts: 268
Joined: Tue Nov 24, 2009 2:20 am


Return to Engine Programming

Who is online

Users browsing this forum: No registered users and 1 guest