Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

100 Neutral

About orcfan32

  • Rank
  1. orcfan32

    2d Collision on the LEFT side of a sprite

    Quote:Original post by Thaumaturgealthough why it doesn't affect the other directions I'm not sure The origin of the sprite in the case of the left wall is always against the left wall. When I say edrawx = edrawx/32*32, it's still setting it's position at the same wall and therefore doing it over and over again. Your check to make sure that the evelx was < 0 works, to an extent. Since the origin of the sprite is still at the left wall, I can press left and it will go through the wall (this being done from DoVelocity). It would be a bit of a hack to get this to work it seems, I could make an invisible block behind the one that the player SHOULD collide with, and use the edrawx = edrawx/32*32+32. Would it work better if I combine the Velocity and Physics functions into one function, or even just forget about velocity?
  2. Hi, I'm using a simple 32x32 tile system for a sidescroller (C++). I've figured out how to work the collision on the bottom, right, and top of a sprite, however the left side is confusing me. When I go to a wall on the sprite's left side, I get stuck there and can't move. The only way to fix it is to put the sprite's position to the right 32 pixels, but obviously there's a problem with not being able to go all the way to the wall. My code is pretty straightforward. I'm taking the sprite and checking ahead, not before moving, which is probably a bad thing. The way I'm calling the player's actions is like this: pc.SendKeys(gamekeys); pc.DoVelocity(); pc.DoPhysics(lvl); pc.DrawTo(screen); Neither the SendKeys or DrawTo code matters. My DoVelocity and DoPhysics is messed up somehow. Below I'm checking to see if the tile is able to be collided with by taking the players draw x and draw y from a float and dividing it by 32 in a way that the result is an integer. This way I can detect the player's coordinates on the map. Then I add an offset. Since the sprite's height is 64, I will add 2 after dividing to an int to detect what the tile below the sprite is. Note that this works fine for the other directions. void DoVelocity() { if (evelx > emaxvel) // I prefixed everything with e in this evelx = emaxvel; // class, don't mind it. vel = velocity. else if (evelx < (emaxvel - (emaxvel * 2))) evelx = (emaxvel - (emaxvel * 2)); edrawx += evelx; edrawy += evely; if (evelx > 0); // Messy and inefficient, don't mind. evelx -= .3; if (evelx < 0); evelx += .3; }; void DoPhysics(Level lvl) { if (lvl.GetLevelData(edrawx/32, edrawy/32+2) == '0') //GetLevelData takes x and y coords and returns what is on that square in the { // multidimensional array. This if block detects the floor. edrawy = edrawy/32*32; evely = 0; jumping = false; } else { evely += .2; } if (lvl.GetLevelData(edrawx/32+1, edrawy/32) == '0') // Right of player { edrawx = edrawx/32*32; evelx = 0; } if (lvl.GetLevelData(edrawx/32+1, edrawy/32+1) == '0') // Same, just by the player's feet, not face. { edrawx = edrawx/32*32; evelx = 0; } if (lvl.GetLevelData(edrawx/32-1, edrawy/32) == '0') // Detection of left, bugged. I can't move when I touch a wall on my left. { edrawx = edrawx/32*32; evelx = 0; } if (lvl.GetLevelData(edrawx/32-1, edrawy/32+1) == '0') // Left at player's feet. { edrawx = edrawx/32*32; evelx = 0; } if (lvl.GetLevelData(edrawx/32, edrawy/32-1) == '0') // Top. { edrawy = edrawy/32*32; evely += .1; } }; I have an idea why it won't work on the left, but I can't seem to explain it well enough. It's like since the very left of the sprite is too close to the wall, if we reset to edrawx/32*32, it gets into an infinite set evelx to 0. Can someone kindly shed some light on this? Any help is appreciated.
  3. I'm having a problem with SDL and blitting raw pixels to surfaces other than the main screen... I have a class called CGF, which consists of this code: Header: #include "Globals.h" class CGF { public: CGF() { surf = NULL; }; CGF(std::string Filename); ~CGF(); SDL_Surface *LoadFile(std::string Filename); SDL_Surface *GetSurface(); private: SDL_Surface *surf; int filewidth; int fileheight; }; Source: #include "Globals.h" #include "CGF.h" void putpixel(SDL_Surface *dest, int x, int y, int color) // Sol's tutorial function { unsigned int *ptr = (unsigned int*)dest->pixels; int lineoffset = y * (dest->pitch / 4); ptr[lineoffset + x] = color; } CGF::CGF(std::string Filename) { surf = NULL; this->surf = this->LoadFile(Filename); } CGF::~CGF() { if (surf == NULL) {} else { SDL_FreeSurface(surf); } } SDL_Surface *CGF::LoadFile(std::string Filename) { FILE *cgf_file = fopen(Filename.c_str(), "rb"); SDL_Surface *tmp = NULL; this->filewidth = -1; this->fileheight = 1; int curchr = 0; int lastchr = 0; int blit_x = 0; int blit_y = 0; if (cgf_file == NULL) { return NULL; } int fchr = 0; while (fchr != '\n' && fchr != '\r') { fchr = fgetc(cgf_file); this->filewidth++; } while (!feof(cgf_file)) { if (fgetc(cgf_file) == fchr) { this->fileheight++; } } fseek(cgf_file, 0, SEEK_SET); while (!feof(cgf_file)) { curchr = fgetc(cgf_file); if (curchr == '*') { putpixel(tmp, blit_x, blit_y, 0xFF00FF); } else if (curchr == 'w') { putpixel(tmp, blit_x, blit_y, 0xFFFFFF); } else if (curchr == '\r' || curchr == '\n' && lastchr != '\r' || lastchr != '\n') { blit_x = -1; blit_y += 1; } lastchr = curchr; blit_x += 1; } fclose(cgf_file); return tmp; } SDL_Surface *CGF::GetSurface() { return this->surf; } Now, when I modify the putpixel function in Sol's SDL tutorials, my app throws an exception when I blit to the surface 'tmp'. I replaced it with my 'screen' which is defined in the globals.h, and it worked perfectly. I looked at both of the definitions of screen and tmp, and they are declared the exact same way, inited as NULL and as a pointer. Unhandled exception at 0x00411b11 in tbs.exe: 0xC0000005: Access violation reading location 0x00000014. Does anyone see a problem with this?
  4. orcfan32

    Help Me Name My Cat

    How about...Moonlight?
  5. Quote:Original post by Rob Loach Quote:Original post by orcfan32 That's strange, when I was using SDL 1.2.10, .OGG's worked just fine.Maybe I was thinking MP3 support. There were some issues with something....... Ah, midi support. That's the first format I tried with SDL_Mixer and it didn't work.
  6. If you're looking for models, try the Help Wanted section...
  7. orcfan32

    Problems with parsing

    Oops, I meant console app.
  8. orcfan32

    Oblivion Mods

    You may find this site helpful for locating mods. I would recommend the Oblivion Enhanced mod, but that's just me. I think that it makes the game seem refreshingly new after beating it. Also, try to make an archer sometime too; they're loads of fun!
  9. Quote:Original post by Rob Loach In a recent version of SDL (1.2.10 I believe), .OGG support broke. This bug was supposedly fixed in the most recent release of SDL (1.2.11). That's strange, when I was using SDL 1.2.10, .OGG's worked just fine. I used this code: int play_sound(std::string Filename) { Mix_Chunk *sound = Mix_LoadWAV(Filename.c_str()); int SChannel = 0; if (sound == NULL) { Mix_FreeChunk(sound); return 1; } else { SChannel = Mix_PlayChannel(-1, sound, 0); while(Mix_Playing(SChannel) != 0); { Mix_FreeChunk(sound); } return 0; } } Unfortunately, I can't compile it ATM because I don't have a compiler. If anyone else wants to have a go at it, go ahead.
  10. orcfan32

    Problems with parsing

    I'm using (was, at least) VS 2005 with a win32 project. Only thing is I can't test your code right now because of a computer breakdown... Anyways, the code I used looks very similar except for the fact that I only read 1 token. However, I ran one test earlier before posting that code that did the while loop and printed the token and value. It still crashed on the string literals when I did it that way. So I'm guessing it's my compiler..?
  11. orcfan32

    Hard disk drive error

    There's about 8 GB of free space left, defragmented last week, no viruses/spyware (scan ran last night). About 4 years since a reinstall, hard drive is the same age... As you can see, I try to keep my hardware at it's best condition. :D My comp just crashed and I got the KERNEL_DATA_INPAGE_ERROR... Great... Guess it's time to start backing up then. I did open my comp case up to check the hard drive's connected cables, then jiggled them, but they seemed pretty tight in there. Thanks for the help.
  12. orcfan32

    Hard disk drive error

    Recently, my computer has been really laggy. I get the infamous blue screen of death after browsing my computer's folders and files. It's at random intervals, and I really don't know what to do about it. So I got the error report after starting up Windows, which takes about 15 minutes to actually be able to do anything. I clicked "Send" which is normally something I wouldn't do. It took me to their page where it says: Quote:Hard disk drive error detected Thank you for submitting an error report. Problem description Windows was temporarily unable to read your hard disk drive. This problem is general in nature and unfortunately we are unable to determine the specific cause of the read error from the error report. In most cases this problem is temporary and can be ignored; however, if the problem is occurring repeatedly we recommend you follow the additional troubleshooting steps in this article. Common causes of this problem include: * Large file transfers from secondary media to local hard drive * Power loss to hard disk drive causing inconsistent data sectors * Problems entering Hibernation or Standby Mode * Hard drive lag caused by filter drivers, such as virus scanners * Bad connection cables, or misconfigured master/slave settings Additional troubleshooting steps The following steps are provided as general troubleshooting steps and may or may not prevent the problem from reoccurring. If you can not resolve the problem using the steps below or are uncomfortable performing the following actions, we recommend you contact your computer manufacturer for assistance. 1. Back up your files and folders immediately to prevent potential data loss. Review the article 320820 to learn how to backup your data. 2. Run a hard disk drive error checking utility. Review the article 315265 to learn how to run a hard disk drive error checking utility. 3. Contact the manufacturer that sold you your hard disk drive for support options. 4. Re-seat or replace the drive cables. 5. Consult your computer documentation or contact your manufacturer for proper drive hardware settings. I've done nothing in the list of common causes that I know of. I was wondering, is it possible that my hard drive's power cable isn't getting an adequate suppy? Or is there something else that you guys would recommend me to do? This is really annoying and I can't even develop in Visual Studio anymore... Just a random thought, could it have anything to do with my computer's last fresh reinstall of Windows was back in 2002?
  13. orcfan32

    A small comic

    Thanks for the nice words everyone. I really didn't think the comic was that great though... [headshake]
  14. orcfan32

    Problems with parsing

    All I did was take the lexer code [lexer.h and lexer.cpp] and added to a blank project (because I'm interested in writing my own someday and I would like to study how they work). Anyways, I went like this in main.cpp: #include "lexer.h" // The file test.txt only contains the following text: // "string literal" int main() { std::ifstream f("test.txt"); base_lexer lexer(f); // I assume this is how this works, I'm not exactly fond of classes tok_type t = lexer.NextToken(); // Read 1 token std::cout<<t.token<<" : "<<t.value<<"\n"; std::cin.get(); return 0; } It crashes like that. But like I commented earlier, I'm not exactly fond of classes. P.S. cnp = copy n pasted P.S.S. Please don't take it the wrong way, I'm not trying to steal your code.
  15. orcfan32

    Nintendo DS

    If you are going to get a GOOD GBA RPG game, then I'd suggest Golden Sun.
  • Advertisement

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!