I came here after a couple weeks of frustration. I dont have much time to talk so ill lay down everything in question form:
1. I have been looking for a simple platform game tutorial done in sdl and c++, you may say "hey check out this site they might have something" but I have probably already checked that site, I would like a direct link.
The type I am looking for includes megaman like movement (the walking, the jumping, the shooting, and the sprite stuff). bonus: basic enemy AI and collectibles like coins and a pause menu.
2. I am looking for a tutorial where I could say, open up notepad, make a layout with letters and symbols, save it as a file and have it load in the game. bonus: have it so I can say, make a file that has the names of all these levels in order so when the game goes to load a new level, it goes down the list.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------
I learn by disecting code, I perfer basic but not too basic (meaning the engine is somewhat there but it is not a full game so its not clustered with stuff) code.
please help me! I am coding a game for the sega dreamcast, but I am going to switch things over to c++ so I need a tutorial. Thanks
Questions and help
For examples, I am using this tutorial of sprites:
and I have these errors:
#include <kos.h>
#include <iostream>
using namespace std;
#include "SDL.h"
#define SCREEN_WIDTH 640
#define SCREEN_HEIGHT 480
#define SPRITE_SIZE 32
int gameover;
/* source and destination rectangles */
SDL_Rect rcSrc, rcSprite;
void HandleEvent(SDL_Event event)
{
switch (event.type) {
/* close button clicked */
case SDL_QUIT:
gameover = 1;
break;
/* handle the keyboard */
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_ESCAPE:
case SDLK_q:
gameover = 1;
break;
case SDLK_LEFT:
if ( rcSrc.x == 192 )
rcSrc.x = 224;
else
rcSrc.x = 192;
rcSprite.x -= 5;
break;
case SDLK_RIGHT:
if ( rcSrc.x == 64 )
rcSrc.x = 96;
else
rcSrc.x = 64;
rcSprite.x += 5;
break;
case SDLK_UP:
if ( rcSrc.x == 0 )
rcSrc.x = 32;
else
rcSrc.x = 0;
rcSprite.y -= 5;
break;
case SDLK_DOWN:
if ( rcSrc.x == 128 )
rcSrc.x = 160;
else
rcSrc.x = 128;
rcSprite.y += 5;
break;
}
break;
}
}
int main(int argc, char* argv[])
{
SDL_Surface *screen, *temp, *sprite, *grass;
SDL_Rect rcGrass;
int colorkey;
/* initialize SDL */
SDL_Init(SDL_INIT_VIDEO);
/* set the title bar */
SDL_WM_SetCaption("SDL Animation", "SDL Animation");
/* create window */
screen = SDL_SetVideoMode(SCREEN_WIDTH, SCREEN_HEIGHT, 0, 0);
/* set keyboard repeat */
SDL_EnableKeyRepeat(70, 70);
/* load sprite */
temp = SDL_LoadBMP("sprite.bmp");
sprite = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
/* setup sprite colorkey and turn on RLE */
colorkey = SDL_MapRGB(screen->format, 255, 0, 255);
SDL_SetColorKey(sprite, SDL_SRCCOLORKEY | SDL_RLEACCEL, colorkey);
/* load grass */
temp = SDL_LoadBMP("grass.bmp");
grass = SDL_DisplayFormat(temp);
SDL_FreeSurface(temp);
/* set sprite position */
rcSprite.x = 150;
rcSprite.y = 150;
/* set animation frame */
rcSrc.x = 128;
rcSrc.y = 0;
rcSrc.w = SPRITE_SIZE;
rcSrc.h = SPRITE_SIZE;
gameover = 0;
/* message pump */
while (!gameover)
{
SDL_Event event;
/* look for an event */
if (SDL_PollEvent(&event)) {
HandleEvent(event);
}
/* collide with edges of screen */
if (rcSprite.x <= 0)
rcSprite.x = 0;
if (rcSprite.x >= SCREEN_WIDTH - SPRITE_SIZE)
rcSprite.x = SCREEN_WIDTH - SPRITE_SIZE;
if (rcSprite.y <= 0)
rcSprite.y = 0;
if (rcSprite.y >= SCREEN_HEIGHT - SPRITE_SIZE)
rcSprite.y = SCREEN_HEIGHT - SPRITE_SIZE;
/* draw the grass */
for (int x = 0; x < SCREEN_WIDTH / SPRITE_SIZE; x++) {
for (int y = 0; y < SCREEN_HEIGHT / SPRITE_SIZE; y++) {
rcGrass.x = x * SPRITE_SIZE;
rcGrass.y = y * SPRITE_SIZE;
SDL_BlitSurface(grass, NULL, screen, &rcGrass);
}
}
/* draw the sprite */
SDL_BlitSurface(sprite, &rcSrc, screen, &rcSprite);
/* update the screen */
SDL_UpdateRect(screen, 0, 0, 0, 0);
}
/* clean up */
SDL_FreeSurface(sprite);
SDL_FreeSurface(grass);
SDL_Quit();
return 0;
}
and I have these errors:
||=== AnnihilaPlatformEngine, default ===|
.objs\main.o||In function `main':|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_Init'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_RWFromFile'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_LoadBMP_RW'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_WM_SetCaption'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_DisplayFormat'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_SetVideoMode'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_EnableKeyRepeat'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_FreeSurface'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_MapRGB'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_SetColorKey'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_PollEvent'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_UpperBlit'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_UpdateRect'|
E:\Nick Lopez\Programming\NICK\AnnihilaPlatformEngine\main.cpp|152|undefined reference to `_SDL_Quit'|
||=== Build finished: 14 errors, 0 warnings ===|
[/quote]
And I am using code blocks from the dc dev iso r4. cygwin and kos and all that stuff are set up and i followed the tutorial exactly. There is absolutely no help on dcemulations site (too dead), and any time this problem occurs, helpers just ignore it. lol
I must program for the dreamcast. There is a way but the current way sucks.
It looks like you're not correctly linking to the SDL library or libraries. I'm not familiar with SDL so I can't give specifics, but I'd expect the SDL documentation to have that information.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement