Alright people.
I would like to know where do I start writing up C, um...and any tutorials on creating a square and then moving it around? And then eventually using a button, several too.
Printable View
Alright people.
I would like to know where do I start writing up C, um...and any tutorials on creating a square and then moving it around? And then eventually using a button, several too.
Have you learnt the language first? There are plenty of tutorials out there - we also have a FAQ and everyone here will be happy to help you.
Drawing a square and moving it around would be graphics programming by the sounds of it. Starting with graphics programming requires a sound foundation in the language you are doing the work in - at least if you want to make some progress and something a bit complicated (like reacting to keypresses and/or mouse/pointer/touchpad movement).
--
Mats
Well, lets say a small square on the screen and then press the arrow key?
No I haven't done any of this...
I am focusing on 2D. Nothing to do with any 3D.
Um, no. I thought it mainly applied to 3D...
For anyone who has used VB. Do you know say e.graphics(pens.white, 20, 20, 20, 20)
Just a line.
?
For Windows, this would be an example:
Create a window
Set a pen colour
select the pen
draw a line
deselect the pen.
close the window (after waiting for some time, perhaps).
If you have no experience in C, you will not be able to do that - it's non-trivial stuff.
Start writing simple console applications first.
--
Mats
Um, could you give me an example?
Of a line or shape in C?
Then that code is debugged and then displays on the screen.
matsp has already said that, in C, doing this is non-trivial. An example would be very long and you would likely not understand most of it unless you know C.
Listen to what we're saying here, learn C thoroghly first, then try your hand at graphics.
Draws an uncolored triangle to the screen.
Code:/*
* This Code Was Created By Jeff Molofee 2000
* A HUGE Thanks To Fredric Echols For Cleaning Up
* And Optimizing The Base Code, Making It More Flexible!
* If You've Found This Code Useful, Please Let Me Know.
* Visit My Site At nehe.gamedev.net
*/
#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library
#include <gl\glaux.h> // Header File For The Glaux Library
HDC hDC=NULL; // Private GDI Device Context
HGLRC hRC=NULL; // Permanent Rendering Context
HWND hWnd=NULL; // Holds Our Window Handle
HINSTANCE hInstance; // Holds The Instance Of The Application
bool keys[256]; // Array Used For The Keyboard Routine
bool active=TRUE; // Window Active Flag Set To TRUE By Default
bool fullscreen=TRUE; // Fullscreen Flag Set To Fullscreen Mode By Default
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); // Declaration For WndProc
GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
int InitGL(GLvoid) // All Setup For OpenGL Goes Here
{
glShadeModel(GL_SMOOTH); // Enable Smooth Shading
glClearColor(0.0f, 0.0f, 0.0f, 0.5f); // Black Background
glClearDepth(1.0f); // Depth Buffer Setup
glEnable(GL_DEPTH_TEST); // Enables Depth Testing
glDepthFunc(GL_LEQUAL); // The Type Of Depth Testing To Do
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST); // Really Nice Perspective Calculations
return TRUE; // Initialization Went OK
}
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
glTranslatef(-1.5f,0.0f,-6.0f); // Move Left 1.5 Units And Into The Screen 6.0
glBegin(GL_TRIANGLES); // Drawing Using Triangles
glVertex3f( 0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glEnd(); // Finished Drawing The Triangle
glTranslatef(3.0f,0.0f,0.0f); // Move Right 3 Units
glBegin(GL_QUADS); // Draw A Quad
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glVertex3f( 1.0f, 1.0f, 0.0f); // Top Right
glVertex3f( 1.0f,-1.0f, 0.0f); // Bottom Right
glVertex3f(-1.0f,-1.0f, 0.0f); // Bottom Left
glEnd(); // Done Drawing The Quad
return TRUE; // Keep Going
}
GLvoid KillGLWindow(GLvoid) // Properly Kill The Window
{
if (fullscreen) // Are We In Fullscreen Mode?
{
ChangeDisplaySettings(NULL,0); // If So Switch Back To The Desktop
ShowCursor(TRUE); // Show Mouse Pointer
}
if (hRC) // Do We Have A Rendering Context?
{
if (!wglMakeCurrent(NULL,NULL)) // Are We Able To Release The DC And RC Contexts?
{
MessageBox(NULL,"Release Of DC And RC Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
if (!wglDeleteContext(hRC)) // Are We Able To Delete The RC?
{
MessageBox(NULL,"Release Rendering Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
}
hRC=NULL; // Set RC To NULL
}
if (hDC && !ReleaseDC(hWnd,hDC)) // Are We Able To Release The DC
{
MessageBox(NULL,"Release Device Context Failed.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hDC=NULL; // Set DC To NULL
}
if (hWnd && !DestroyWindow(hWnd)) // Are We Able To Destroy The Window?
{
MessageBox(NULL,"Could Not Release hWnd.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hWnd=NULL; // Set hWnd To NULL
}
if (!UnregisterClass("OpenGL",hInstance)) // Are We Able To Unregister Class
{
MessageBox(NULL,"Could Not Unregister Class.","SHUTDOWN ERROR",MB_OK | MB_ICONINFORMATION);
hInstance=NULL; // Set hInstance To NULL
}
}
/* This Code Creates Our OpenGL Window. Parameters Are: *
* title - Title To Appear At The Top Of The Window *
* width - Width Of The GL Window Or Fullscreen Mode *
* height - Height Of The GL Window Or Fullscreen Mode *
* bits - Number Of Bits To Use For Color (8/16/24/32) *
* fullscreenflag - Use Fullscreen Mode (TRUE) Or Windowed Mode (FALSE) */
BOOL CreateGLWindow(char* title, int width, int height, int bits, bool fullscreenflag)
{
GLuint PixelFormat; // Holds The Results After Searching For A Match
WNDCLASS wc; // Windows Class Structure
DWORD dwExStyle; // Window Extended Style
DWORD dwStyle; // Window Style
RECT WindowRect; // Grabs Rectangle Upper Left / Lower Right Values
WindowRect.left=(long)0; // Set Left Value To 0
WindowRect.right=(long)width; // Set Right Value To Requested Width
WindowRect.top=(long)0; // Set Top Value To 0
WindowRect.bottom=(long)height; // Set Bottom Value To Requested Height
fullscreen=fullscreenflag; // Set The Global Fullscreen Flag
hInstance = GetModuleHandle(NULL); // Grab An Instance For Our Window
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; // Redraw On Size, And Own DC For Window.
wc.lpfnWndProc = (WNDPROC) WndProc; // WndProc Handles Messages
wc.cbClsExtra = 0; // No Extra Window Data
wc.cbWndExtra = 0; // No Extra Window Data
wc.hInstance = hInstance; // Set The Instance
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); // Load The Default Icon
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load The Arrow Pointer
wc.hbrBackground = NULL; // No Background Required For GL
wc.lpszMenuName = NULL; // We Don't Want A Menu
wc.lpszClassName = "OpenGL"; // Set The Class Name
if (!RegisterClass(&wc)) // Attempt To Register The Window Class
{
MessageBox(NULL,"Failed To Register The Window Class.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if (fullscreen) // Attempt Fullscreen Mode?
{
DEVMODE dmScreenSettings; // Device Mode
memset(&dmScreenSettings,0,sizeof(dmScreenSettings)); // Makes Sure Memory's Cleared
dmScreenSettings.dmSize=sizeof(dmScreenSettings); // Size Of The Devmode Structure
dmScreenSettings.dmPelsWidth = width; // Selected Screen Width
dmScreenSettings.dmPelsHeight = height; // Selected Screen Height
dmScreenSettings.dmBitsPerPel = bits; // Selected Bits Per Pixel
dmScreenSettings.dmFields=DM_BITSPERPEL|DM_PELSWIDTH|DM_PELSHEIGHT;
// Try To Set Selected Mode And Get Results. NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
if (ChangeDisplaySettings(&dmScreenSettings,CDS_FULLSCREEN)!=DISP_CHANGE_SUCCESSFUL)
{
// If The Mode Fails, Offer Two Options. Quit Or Use Windowed Mode.
if (MessageBox(NULL,"The Requested Fullscreen Mode Is Not Supported By\nYour Video Card. Use Windowed Mode Instead?","NeHe GL",MB_YESNO|MB_ICONEXCLAMATION)==IDYES)
{
fullscreen=FALSE; // Windowed Mode Selected. Fullscreen = FALSE
}
else
{
// Pop Up A Message Box Letting User Know The Program Is Closing.
MessageBox(NULL,"Program Will Now Close.","ERROR",MB_OK|MB_ICONSTOP);
return FALSE; // Return FALSE
}
}
}
if (fullscreen) // Are We Still In Fullscreen Mode?
{
dwExStyle=WS_EX_APPWINDOW; // Window Extended Style
dwStyle=WS_POPUP; // Windows Style
ShowCursor(FALSE); // Hide Mouse Pointer
}
else
{
dwExStyle=WS_EX_APPWINDOW | WS_EX_WINDOWEDGE; // Window Extended Style
dwStyle=WS_OVERLAPPEDWINDOW; // Windows Style
}
AdjustWindowRectEx(&WindowRect, dwStyle, FALSE, dwExStyle); // Adjust Window To True Requested Size
// Create The Window
if (!(hWnd=CreateWindowEx( dwExStyle, // Extended Style For The Window
"OpenGL", // Class Name
title, // Window Title
dwStyle | // Defined Window Style
WS_CLIPSIBLINGS | // Required Window Style
WS_CLIPCHILDREN, // Required Window Style
0, 0, // Window Position
WindowRect.right-WindowRect.left, // Calculate Window Width
WindowRect.bottom-WindowRect.top, // Calculate Window Height
NULL, // No Parent Window
NULL, // No Menu
hInstance, // Instance
NULL))) // Dont Pass Anything To WM_CREATE
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Window Creation Error.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
static PIXELFORMATDESCRIPTOR pfd= // pfd Tells Windows How We Want Things To Be
{
sizeof(PIXELFORMATDESCRIPTOR), // Size Of This Pixel Format Descriptor
1, // Version Number
PFD_DRAW_TO_WINDOW | // Format Must Support Window
PFD_SUPPORT_OPENGL | // Format Must Support OpenGL
PFD_DOUBLEBUFFER, // Must Support Double Buffering
PFD_TYPE_RGBA, // Request An RGBA Format
bits, // Select Our Color Depth
0, 0, 0, 0, 0, 0, // Color Bits Ignored
0, // No Alpha Buffer
0, // Shift Bit Ignored
0, // No Accumulation Buffer
0, 0, 0, 0, // Accumulation Bits Ignored
16, // 16Bit Z-Buffer (Depth Buffer)
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
if (!(hDC=GetDC(hWnd))) // Did We Get A Device Context?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Create A GL Device Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if (!(PixelFormat=ChoosePixelFormat(hDC,&pfd))) // Did Windows Find A Matching Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Find A Suitable PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if(!SetPixelFormat(hDC,PixelFormat,&pfd)) // Are We Able To Set The Pixel Format?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Set The PixelFormat.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if (!(hRC=wglCreateContext(hDC))) // Are We Able To Get A Rendering Context?
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Create A GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
if(!wglMakeCurrent(hDC,hRC)) // Try To Activate The Rendering Context
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Can't Activate The GL Rendering Context.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
ShowWindow(hWnd,SW_SHOW); // Show The Window
SetForegroundWindow(hWnd); // Slightly Higher Priority
SetFocus(hWnd); // Sets Keyboard Focus To The Window
ReSizeGLScene(width, height); // Set Up Our Perspective GL Screen
if (!InitGL()) // Initialize Our Newly Created GL Window
{
KillGLWindow(); // Reset The Display
MessageBox(NULL,"Initialization Failed.","ERROR",MB_OK|MB_ICONEXCLAMATION);
return FALSE; // Return FALSE
}
return TRUE; // Success
}
LRESULT CALLBACK WndProc( HWND hWnd, // Handle For This Window
UINT uMsg, // Message For This Window
WPARAM wParam, // Additional Message Information
LPARAM lParam) // Additional Message Information
{
switch (uMsg) // Check For Windows Messages
{
case WM_ACTIVATE: // Watch For Window Activate Message
{
if (!HIWORD(wParam)) // Check Minimization State
{
active=TRUE; // Program Is Active
}
else
{
active=FALSE; // Program Is No Longer Active
}
return 0; // Return To The Message Loop
}
case WM_SYSCOMMAND:
{
switch (wParam)
{
case SC_SCREENSAVE:
case SC_MONITORPOWER:
return 0;
}
break;
}
case WM_CLOSE: // Did We Receive A Close Message?
{
PostQuitMessage(0); // Send A Quit Message
return 0; // Jump Back
}
case WM_KEYDOWN: // Is A Key Being Held Down?
{
keys[wParam] = TRUE; // If So, Mark It As TRUE
return 0; // Jump Back
}
case WM_KEYUP: // Has A Key Been Released?
{
keys[wParam] = FALSE; // If So, Mark It As FALSE
return 0; // Jump Back
}
case WM_SIZE: // Resize The OpenGL Window
{
ReSizeGLScene(LOWORD(lParam),HIWORD(lParam)); // LoWord=Width, HiWord=Height
return 0; // Jump Back
}
}
// Pass All Unhandled Messages To DefWindowProc
return DefWindowProc(hWnd,uMsg,wParam,lParam);
}
int WINAPI WinMain( HINSTANCE hInstance, // Instance
HINSTANCE hPrevInstance, // Previous Instance
LPSTR lpCmdLine, // Command Line Parameters
int nCmdShow) // Window Show State
{
MSG msg; // Windows Message Structure
BOOL done=FALSE; // Bool Variable To Exit Loop
// Ask The User Which Screen Mode They Prefer
if (MessageBox(NULL,"Would You Like To Run In Fullscreen Mode?", "Start FullScreen?",MB_YESNO|MB_ICONQUESTION)==IDNO)
{
fullscreen=FALSE; // Windowed Mode
}
// Create Our OpenGL Window
if (!CreateGLWindow("NeHe's First Polygon Tutorial",640,480,16,fullscreen))
{
return 0; // Quit If Window Was Not Created
}
while(!done) // Loop That Runs While done=FALSE
{
if (PeekMessage(&msg,NULL,0,0,PM_REMOVE)) // Is There A Message Waiting?
{
if (msg.message==WM_QUIT) // Have We Received A Quit Message?
{
done=TRUE; // If So done=TRUE
}
else // If Not, Deal With Window Messages
{
TranslateMessage(&msg); // Translate The Message
DispatchMessage(&msg); // Dispatch The Message
}
}
else // If There Are No Messages
{
// Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
if ((active && !DrawGLScene()) || keys[VK_ESCAPE]) // Active? Was There A Quit Received?
{
done=TRUE; // ESC or DrawGLScene Signalled A Quit
}
else // Not Time To Quit, Update Screen
{
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
}
if (keys[VK_F1]) // Is F1 Being Pressed?
{
keys[VK_F1]=FALSE; // If So Make Key FALSE
KillGLWindow(); // Kill Our Current Window
fullscreen=!fullscreen; // Toggle Fullscreen / Windowed Mode
// Recreate Our OpenGL Window
if (!CreateGLWindow("NeHe's First Polygon Tutorial",640,480,16,fullscreen))
{
return 0; // Quit If Window Was Not Created
}
}
}
}
// Shutdown
KillGLWindow(); // Kill The Window
return (msg.wParam); // Exit The Program
}
see what they were trying to tell you?
I'd like to run this code, please?
umm compile it?
We are trying to tell you, start small. Don't jump right into graphics. It is just a bad idea. Learn the language. Countless resources for learning C or C++ are lingering around the internet. You need to understand the language and know how to use a compiler to be able to do these things.
Well if you know a bit about pointers, and a bit about graphics coding in general then you should be able to have a go at doing some simple graphics stuff in C. That said by the sounds of things you may need to learn some more basic stuff first. You could try SDL, it would be simpler to get into than windows.h with open gl.
Heres a prog that draws a sinewave:
If you can get the SDL development files set up + create a project and link it. Then you can run this code and play around with writing pixels. Theres plenty of SDL tutorials around on the net.Code:#include <SDL\SDL.h>
#include <math.h>
#define GRAPHICS_WIDTH 256
#define GRAPHICS_HEIGHT 256
#define BITDEPTH 32
#define DEG_TO_RAD 0.0174532925
SDL_Surface *screen = NULL; //This will be the screen buffer
void WritePixel(int x, int y, Uint32 col)
{
if(x < 0 || x >= GRAPHICS_WIDTH)
return;
if(y < 0 || y >= GRAPHICS_HEIGHT)
return;
Uint32 *pix;
pix=(Uint32*)screen->pixels+(x+y*GRAPHICS_WIDTH)*4;
*pix=col;
}
int main()
{
//First we set up the screen. If something goes wrong quit the prog.
if(SDL_Init(SDL_INIT_VIDEO) !=0)
return 1;
screen = SDL_SetVideoMode(GRAPHICS_WIDTH, GRAPHICS_HEIGHT, BITDEPTH, 0);
if(screen == NULL)
return 1;
//Draw a crude sine wave
int x;
for(x=0; x<GRAPHICS_WIDTH; x++)
WritePixel(x, (int)128+cos(x*DEG_TO_RAD)*100, 0xFFFFFFFF);
//The screen buffer needs to be flipped in order to display
if(SDL_Flip(screen)==-1)
return 1;
SDL_Delay(3000);
SDL_Quit();
return 0;
}
You mentioned a keyword there, project files / linking ?
Yes. If you are going to have a go at sdl theres a tutorial for this here:
http://lazyfoo.net/SDL_tutorials/lesson01/index.php
Which covers setting SDL up and linking it with many different operating systems and IDEs.
I think Acer might be more interested in a game engine rather then doing everything by hand.
Do you know what SDL is?
Yeah, but I meant a higher level application game engine.
SDL is a great tool much like OpenGL and Direct3D. However it is just like all other tools in software and in any other field. You must know how to utilize the tool in order to be effective with it.
I tire quickly of suggestions to use this or that API solely based on the fact the the OP does not have a grasp of the fundamentals of the language. Please do not use A or B API just to stay away from the nitty gritty or because you don't want to learn. If you do this I guarantee you utter failure. Do this the right way and learn the language top to bottom. Then learn 2D or 3D concepts top to bottom. Then you can make the choice of which API you will use to aid you in creating your game. Doing this in any other order is just a recipe for disaster.
I find it very disturbing that some of our members continually suggest this or that API to people and claim it's easy or keeps you away from the hard stuff. Game programming is hard. Graphics programming is hard. 3D graphics programming is extremely hard. If you are trying to avoid the learning curve you are already going down the wrong path.
1. Learn the language. Learn the concepts.
2. Learn about game code through coding, books, internet, etc.
3. Learn about 2D/3D through coding, books, internet, etc.
4. Once you have a grasp of these things you can then choose your API.
None of us here have created anything that I would call a 'complete' 3D game. It is not a simple task to undertake even if you know the language very well and also know your API very well.
We could show you all manner of matrix transforms, C/C++ code, HLSL code, etc, but it would blow you away. It's too much and we could never explain it all here. Take the advice of the members here who have told you to take it slow and learn the language. I'm not saying don't code. Quite the contrary I would code as much as possible to complement my research and learning. I do not recommend getting your hands on a 3D engine and trying to wedge your own stuff in without knowing how it all works or at least the fundamentals of how it works. You will just get frustrated and probably quit. Be fair to yourself and be fair to the breadth of the information that is out there. Trying to code a 3D or even 2D game with no knowledge is not fair to yourself. Go slow and eventually it all starts to come together and make sense.
Please do not take our advice as just negativity. We, more than anyone, want you to learn and want you to succeed. However we see your kind a lot here and usually they die off in a few months. Enthusiasm is great but it won't keep you. Enthusiasm tempered with reality and facts will keep you going depsite the problems you may encounter. If you need assistance these forums are a great place to get help provided you have attempted programming and/or shown at least some effort. I wish you well on your journey into game programming. In the end it's fun and very rewarding. Just make sure you have a huge Tylenol or Advil bottle with you because there are many headaches down the road.
Thank you Bubba, I'm not a full on programmer.
I've done little of vb. I am trying out 2d gfx as it is easier.
For windows mobile. 2D game.
I'm also actually trying to move away from computers in a technical manner.
Visual Basic = weak sauce
Like everyone else has said so far, you need to learn the language of C or C++ before you get into graphics using either of those languages. You can find several good books at bookstores all over the place.
I think even microsoft is trying to get people to move away from visual basic. I read somewhere that they intend to discontinue development of VB in 2012 and stop support in 2020. Not sure if it was a MS website or someone elses, btu I do know they intend to deprecate VB in the not too distant future.
Oh well since I learned VB at college very little.
You get my drift?
Stick with it, and continue since it is slightly easier and there is only that for WM. That has no hassles.
If I wanted to do C how do I get the buttons to work?
For anyone who has done pocket programming, you click on the form in VS and click on the buttons, type your code etc. Done and dusted!
And then there is palm ?
I read that there is a c compiler for palm, so you could program on the device....
But again all that issue of having a "mobile template" for a device just complicates things.
Please do not use A or B API just to stay away from the nitty gritty or because you don't want to learn. If you do this I guarantee you utter failure. Do this the right way and learn the language top to bottom.
Even focusing on just what you want to learn? Is that not possible?
You have never programmed in C or C++ and have very little programming experiences at all, just a bit of VB.
Any you want to create a game from a mobile phone? After all the tips and advices you have been given, it is very nice of people to not flame you, but I bet several of the people posted here wanted to....
Best of luck
Hang on buddy.
What do you mean ?
I know I don't know much about anything to do with this subject. But as silly as it sounds I did explain myself as not being a full on programmer.
So some of you if not most are saying that trying to take this up wouldn't be much point. Even if what you want to do is so small.
I'm not talking about making huge levels, or 3D. Only very basic 2D using the GDI of the pc.
No images, no stats no menus etc.
So you want to build games, but you don't want to learn how to write software. Hmm.
This might be a great start,
Intro: http://www.youtube.com/watch?v=djHD30qlL-A
Site: http://mygamebuilder.com/
Enjoy!
AcerN30, the thing that you are not understanding here is the idea of abstraction. Visual Basic abstracts all the nitty-gritty stuff from you. In other words, it hides all the deep stuff from you and gives you these simple 1-line commands to do the things you want. Abstraction can be a good thing, and at times it can be a bad thing.
In terms of abstraction, C and C++ do not do as much abstraction for you as Visual Basic. Hence you have to write much more code in order to create windows, draw squares, and do many tasks that would take less lines of code in Visual Basic. Is this a bad thing? No. C and C++ programs perform hundreds of times more efficiently than Visual Basic programs do, and they truly give the programmer access to the system. But to be proficient in C and C++ you need to know what you are doing. You need to know at the very least know how memory/pointers work, or else you will completely fall on your face.
You are frustrated because you cannot do the same things in one line of code in C/C++ as you could do in Visual Basic, but you are not putting forth the effort or showing any willingness to learn how things are properly supposed to be done in the C/C++ languages. Be willing to learn.
Does this mean that there is no way to reduce the amount of lines of code that exist in a C/C++ program? No. There are several APIs that programmers use that provide nice functionality for them and some additional levels of abstraction, but you need to understand how to program in the standard C/C++ language before you start using those APIs.
Close to impossibleQuote:
Hmm, so just trying to learn the gfx part would be pointless without learning A? then b
I recommend downloading a compiler and start some tutorialsQuote:
With VB, you have a template. Where is that with C?
dittoQuote:
so just trying to learn the gfx part would be pointless
I haven't programmed in Visual Basic since the 8th grade (that's....10 years ago?), so I really quite honestly don't know what a VB "template" is. I assume it is some kind of pre-made project template that already has some code written for you....? Is that what you mean?Quote:
With VB, you have a template. Where is that with C?
Maybe you could try C++. It supports OOP (ie classes), which is a bit closer to VB. Many frameworks are also written in C++.
With C++, it is typically easier to do abstraction (IMHO) and it allows you to get closer to typical VB syntax.
Not to mention, most games are written in C++.
For handhelds and embedded devices and stuff, usually C is the way to go for some reason. But since C++ has its roots in C, it can do everything C can (technical: it fully supports C89, not C99), so there's no bad thing in going for C++ and learning for both your C and C++ needs.
I would say a VB template and a C++ template are quite different. They are not even playing on the same field. A C++ template is far more complex than anything you will find in VB.
I think the common thread here is that you need to learn C/C++ prior to really trying to start on any projects using it. Small console apps will help you learn the language and then you can gradually step up. Keep in mind since C++ is very abstract as has been pointed out programming with C++ in Windows is going to require a significant amount of code as well as some rudimentary Win32 API and Win32 fundamental knowledge. Even knowing the API won't help if you don't know how a Win32 program actually works.
Take it slow, be open and willing to learn new things, ask questions, code, code, code, code, and you will be well on your way to learning what you need to get the job done.
C/C++ are not the only languages out there (thank goodness) but they are both extremely powerful and extremely efficient languages. The only language that tops the performance of these is pure assembly and only if its hand-tuned. C/C++ puts a lot of power in the hands of the programmer, but how, when, and where to use that power is really not that apparent and requires a lot of learning. It's my personal opinion but right now C/C++ is the most powerful language out there. I haven't come across anything else that I like nearly as much as C/C++.
I just wanted to say, I did find that there was a compiler for the python language some time back.
But it wasn't complete you couldn't run any code.
Um, the mobile template is a image template that shows a pocket pc, with the buttons etc
You click on these parts of the pda and it opens into the code window.
You then type out you're code.
I think maybe the only free alternative is C++ visual thing, whatever on the MS site with a mobile template.
I'm viewing this board on my pocket pc.
Windows mobile 2003
32mb rom, 55mb ram, 266mhz processor.
Using C or + whatever i could make it small and efficient if this were to work out...
http://www.amazon.co.uk/gp/aw/d.html...503863Y8768839
I could get this?
That would work, or any of these
There are several free C and C++ compilers. gcc is one, and is also one of the most used. You can go with Visual Studio Express as well.
Another option to consider is C++ Builder.
It is my personal opinion that you should start by downloading GCC, get a good book (like from Amazon), learn the language by using those tools, and then move into Visual Studio Express, C++Builder, or one of those other things.
You mentioned Python. Python is a completely different language, but it is also a very good language. The Python interpreter can be found here. But I wouldn't worry about Python right now if you want to focus on C or C++.
Well my main reason for making a game is for the pocket pc using C.
No one here has done this?
Apparently not but that doesn't mean we can't help you if you start doing it yourself.
Software and code work the same regardless of the platform. The principles remain the same albeit the implementation may differ somewhat,
Looks very complicated.
is the above line a custom function or a library function?Code:WritePixel(x, (int)128+cos(x*DEG_TO_RAD)*100, 0xFFFFFFFF);
Closed. Please don't bump old threads.