Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Everything posted by DominicHughes

  1. Finally copyed a block of pixels now just need to do that 10-20 times and move the orginal and copyed pixels up and down ,position them correctly , and wala pixelated water :D then going to figure out how to smooth it http://i.imgur.com/vEuD9.png
  2. Hi all I'm able to draw pixels in many ways and get pixel values and place them somewhere on the screen surface but when It happens the left over pixel is still there and I was hoping someone could show me code and explain how to remove it from the screen surface here is my code to draw and to get pixels : #include <SDL/SDL.h> #include <SDL/SDL_image.h> #include <math.h> #undef main int y = 10; int x = 10; int x2 = 40; int y2 = 40; SDL_Surface *Screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE), *Image; void pixeldraw(int x, int y , int color) { unsigned int *ptr = static_cast <unsigned int *> (Screen->pixels); int offset = y * (Screen->pitch / sizeof(unsigned int)); ptr[offset + x] = color; } unsigned int pixelget(int x, int y) { unsigned int *ptr = static_cast <unsigned int *> (Screen->pixels); int offset = y * (Screen->pitch / sizeof(unsigned int)); return ptr[offset + x]; } int main(int argc , char *argv[]) { SDL_WM_SetCaption("Image Pixel Manipulation", "PM"); Image = IMG_Load("image.png"); //unsigned int *src0 = (unsigned int *) Image->pixels + y * //Image->pitch; SDL_FillRect(Screen,NULL,(0,0,0)); pixeldraw(10, 10, 0x0000FF); unsigned int color = pixelget(10, 10); pixeldraw(x2,y2, color); printf("%08x\n", color); //unsigned int *pixels = (unsigned int*) Screen->pixels; //unsigned int color = pixels[y * (Screen->pitch / /sizeof(unsigned int)) + x]; // pixels[y2 * (Screen->pitch / sizeof(unsigned int) + x2] = color; //src0[1] = 0; bool done = false; SDL_Event event; while(!done) { //SDL_BlitSurface(Image,NULL,Screen,NULL); while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_QUIT: return 0; break; } } SDL_Flip(Screen); } return 0; } any tips and suggestions are also welcome although this was intended as a test case not a perfect example of coding grammatically and correctly per-say of my ability. Thanks for anyone who reads this .
  3. No, I'm creating an empty surface, then altering the pixels on that surface. I then draw the altered surface onto the screen. Why are we comparing surfaces?[/quote] I'm not comparing surfaces, I'm altering one surface (updating it every 1/10th of a second), and drawing it onto the screen (a second surface) every frame. How are you setting the area of which the pixels values can be gotten and placed elsewhere?[/quote] I'm not setting the area, I'm passing in the surface to the WritePixel() and ReadPixel() functions. I'm getting and reading pixels from a surface. Actually, to be more exact, I didn't do any pixel-reading at all, just writing. In SDL, a "surface" is a image that exists in memory. I'm editing that image; I'm not editing the screen. I'm editing the image, then I'm drawing the image onto the screen. Quote a line of code, then ask about any specific line of code you have questions about - make sure your specify exactly what part you don't understand. [/quote] Okay so return pixels[offset + x]; how does return of pixels[offset + x]; work exactly? Why are you locking surfaces to access pixels to stop tearing or something? this function below makes a rect filling it with a user defined color yes? void DrawRectangle(SDL_Surface *destination, const SDL_Color &color, SDL_Rect *rect = NULL) {SDL_FillRect(destination, rect, SDL_MapRGB(destination->format, color.r, color.g, color.b));} this code is fairly hard to grasp the technical concepts SDL_Surface *CreateEmptySurface(int width, int height, SDL_Surface *surfaceToCompareTo){ SDL_Surface *newSurface = SDL_CreateRGBSurface(surfaceToCompareTo->flags, int width, int height, surfaceToCompareTo->format->BitsPerPixel, surfaceToCompareTo->format->Rmask, surfaceToCompareTo->format->Gmask, surfaceToCompareTo->format->Bmask, surfaceToCompareTo->format->Amask); if(!newSurface) {std::cerr << "CreateEmptySurface() - Something went wrong creating a " << width << "x" << height << " surface.\n" << " Error: " << SDL_GetError() << std::endl;} //Let's start off filling it with a solid color, like solid white. DrawRectangle(newSurface, SDL_Color(255, 255, 255)); return newSurface;} What does this do from a technical point of view SDL_Surface *waterImage = CreateEmptySurface(50, 50, screen); This code below is oddly written what does that all mean ? void MakeWaterSurface(SDL_Surface *surface, unsigned int frame){ //We only have 20 frames, so keep within range. frame %= 20; int offset = frame; if(offset >= 10) { //0 1 2 3 4 5 6 7 8 9 10 9 8 7 6 5 4 3 2 1 offset = (10 - (offset - 10)); } SDL_Color colors[] = {SDL_Color(100, 150, 190),SDL_Color(100, 160, 180),SDL_Color(100, 170, 170),SDL_Color(100, 180, 160),SDL_Color(100, 190, 150), SDL_Color(100, 190, 170),SDL_Color(100, 190, 190),SDL_Color(100, 190, 210),SDL_Color(100, 190, 230),SDL_Color(100, 220, 250)}; for(int y = 0; y < surface->height; y++) { for(int x = 0; x < surface->height; x++) { //I'm coding blind without a compiler, so I have completely no idea if this will work or not. int waveDepth = ((y + offset) % 10); int waveHorizontalOffset = ((x + (offset/3)) % 20); int waveVerticalOffset = ((x + waveHorizontalOffset) + offset); unsigned colorIndex = (waveDepth + waveVerticalOffset) % 10; WritePixel(x, y, colors[colorIndex], surface); } }} Theres still more for me to look at but this is as far as I've gotten in trying to understand not used any of this yet. [/quote]
  4. Been working on The Fish Pond game finally onto the pixel animated cinematic introduction sequence then will work on the player whilst still working on silly platformer which is taking alot of code learning.
  5. I generally have no idea about all of this accept my 2 functions , it would be awesome if someone could do like a simplist explanation on all this new stuff so I can see and know whats going on . Your drawing a rectangle for the water right then altering the pixels on that rectangle how? Why are we comparing surfaces? How are you setting the area of which the pixels values can be gotten and placed elsewhere? yes a full explanation is required !
  6. 1) What type of pixels are you looking to "detect"? Are they a certain color? Image pixels as in the pixels in the PNG Image which is RGBA 32bpp "That could be wrong format". 2) What type of pixels do you consider "garbage"? What makes them "garbage" - their color or some action? There garbage if a pixel value and location is left-over after one pixel value is gotten and placed in a different location. 3) You said detect "around" the area of the garbage pixel. What does "around" mean? One pixel around? Two pixels around? Detect the pixels around the area as in any area I specify could be 40 by 40 pixels or 100 by 100 pixels. 4A) Could you also explain, carefully (it takes me some time to understand ), what it is, in detail, that you are wanting (and why)? To make a wave effect by moving 40 by 40 pixels up and down in a png image. So I can have a decent and cool water effect without loading in each frame of animation of a Adobe After Effects Water Animation . 4B) How are you currently attempting it? I don't actually know the code to get rid of pixel in a png image which has already been found from pixelget which puts in a different location with the pixel found by the function pixelget. 5A) What is the correct result that you'd like? 1.) having user-defined way to put in the x and y values of the area of pixels 2.) to find and place the pixels in a different location using the x and y values. 5B) What is the wrong result your current attempt is giving you? Well I can get values and place them somewhere else but not automatically and in a area specified by me in the x and y .
  7. Servant the lord : I know I have to redraw over it but how can I detect the pixels around the area of the garbage pixel automatically? I don't know the code to do it.
  8. Just finished the player movement mostly in my platformer game just gotta round out a few edges and glitches then I literally can work on the first level and this will get finished without worry or doubt what so ever . :) chocobo racer is on halt till I come up with a solution.
  10. no matter how hard life gets keep going you will understand why eventually ;)
  11. Finally for frick sake got OpenGL working now just need to fix the color format of the texture and make the Quad FullScreen and Rinse and Repeat ! :]
  12. Hi! I was hoping someone could tell me what is required to multiply the pixels on an PNG Loaded Surface "What I mean is zoom the png file so its bigger then its orginal PNG Loaded size on a SDL Surface" I'm able to manipulate just normal pixels and put them on the screen and make gradient rectangles with them but I really don't understand how to do the multiplication on the PNG loaded Surface pixels my thought was too : get the surface->pixels member and then get the width and height store them all in separate variables then multiply them then load them back into surface->pixels member if that's even possible am I correct? probably wrong ;/ any solutions? ;/ #include <SDL/SDL.h> #include <SDL/SDL_Image.h> #include <iostream> #include <math.h> #undef main using namespace std; SDL_Surface *Screen = SDL_SetVideoMode(640,480,32,SDL_SWSURFACE); void pixeltest(int x, int y , int color) { unsigned int *poo = static_cast <unsigned int *> (Screen->pixels); int offset = y * (Screen->pitch / sizeof(unsigned int)); for(x = 0; x <= 1000; x++) poo[offset + x] = color; } int main(int argc, char *argv[]) { SDL_Surface *PNG , *Imagetest; SDL_Color WhiteColor={255,255,255}; PNG = IMG_Load("ChocoLeft1.png"); Uint8* keystate; keystate = SDL_GetKeyState(NULL); //SDL_LockSurface(PNG); int pngy = 0; int pngx = 0; int pngcolor = 0; unsigned int *pngptr = static_cast <unsigned int *> (PNG->pixels); int pngoffset = pngy * (PNG->pitch / sizeof(unsigned int)); bool done = false; SDL_Event event; keystate = SDL_GetKeyState(0); while(!done) { SDL_FillRect(Screen,NULL,0xffff26); SDL_BlitSurface(PNG,NULL,Screen,NULL); for(pngx = 0; pngx <= 100; pngx++) pngptr[pngoffset + pngx] = pngcolor; while(SDL_PollEvent(&event)) { switch(event.type) { case SDL_QUIT: return 0; break; } } SDL_Flip(Screen); } }
  13. Turns out pygame has the ability to smoothscale which means I'm going to do a complete rewrite of Chocobo Racer C++ your a pain in the ass to work with sometimes although I could have rewrite the game in old opengl in C++ but ah well python is much funnier to work with : )
  14. Hello I'm trying to set my zooming Cairo surface to a different z order then the SDL surface so that the Cairo surface is infront of the SDL surface but its not working. My guess was just to switch the order of both the Cairo surface and SDL surface but no luck ;/ if(ZOrderSwitch == false) { cout << " Z Order Set to False" << endl; ChocoFrontStorageRect = ChocoFrontRect; cairo_paint(Fences); cairo_surface_flush(FenceSurf); SDL_BlitSurface(CGTextSurf,NULL,Screen,&CrazyRect); SDL_BlitSurface(ChocoFrontSurf[ChocoFrontFrameTimer],NULL,Screen,&ChocoFrontStorageRect); cairo_surface_mark_dirty(FenceSurf); } else { cout << "Z Order Set to True" << endl; ChocoFrontStorageRect = ChocoFrontRect; cairo_surface_flush(FenceSurf); SDL_BlitSurface(CGTextSurf,NULL,Screen,&CrazyRect); SDL_BlitSurface(ChocoFrontSurf[ChocoFrontFrameTimer],NULL,Screen,&ChocoFrontStorageRect); cairo_surface_mark_dirty(FenceSurf); cairo_paint(Fences); } if(FenceRect.x <= 40) { ZOrderSwitch = true; }
  15. working on my official indie game company website -> http://i.imgur.com/IuID4.png
  16. Finally got Cairo mostly working in my game so now I have access to tons of graphical abilitys now from scaling to rotation you name it ! ;] http://www.cairographics.org/cairo-banner.png
  17. Hello just ran into a problem I don't understand why it is happening? I'm trying to use cairo with sdl obviously but having issues with the functions that I'm so posed to use mainly because the header / cpp file naming "cairosdl.h" and "cairosdl.c" are full of errors when included in my main.cpp file so I was hoping someone could tell me what these errors mean to help in my quest of fixing this problem thank you ! I don't really understand them. here is a pastebin too the cmd shell error outputs -> http://pastebin.com/vEuJNfYs and here are the functions I used below cairo_surface_t *cairosurf = cairo_image_surface_create_for_data ( static_cast<unsigned char *>(sdlsurf->pixels), CAIRO_FORMAT_RGB24, sdlsurf->w, sdlsurf->h, sdlsurf->pitch); cairo_t *cr = cairosdl_create(sdlsurf); cairo_set_source_rgba(cr, 1,1,0,0.5); cairo_rectangle(cr, 25,25,50,50); cairo_fill(cr); cairosdl_destroy(cr); cairo_select_font_face (cr, "serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD); cairo_set_font_size (cr, 32.0); cairo_set_source_rgb (cr, 0.0, 0.0, 1.0); cairo_move_to (cr, 10.0, 50.0); cairo_show_text(cr,"Hello, world");
  18. Hello I've been programming for almost 3 years and having troubles finding simple and basic information on DirectX 10 for example a simple basic directx 10 window? I've looked around on Google with results that show me what I don't want to see... like I've never used Classes before in my games I've programmed and having to deciper through someones uses of classes is very agitating. I looked at the SDK examples and found usefull stuff but no nice descriptions and it would just be nicer if someone had a site or some kind of book that explained how to setup and use DirectX 10 with mingw32 I'm having issues with the makefile setup process includes/lib folders for some reason when I shouldn't be...??? Makefile all: 3DGameProgramming 3DGameProgramming: main.cpp mingw32-g++ main.cpp -o 3DGP -lmingw32 -lwinmm -ld3d9 -mwindows -I"C:\\Program Files\\Microsoft DirectX SDK (June 2010)\\Include" -L"C:\\Program Files\\Microsoft DirectX SDK (June 2010)\\Lib" # this is optional, but it's nice .PHONY: all like in SDL you can find a basic SDL window example.. so if anyone knows anything about DirectX 10 and Mingw32 setups or knows where to find simple basic information on DirectX 10 let me know thank you ! ;]
  19. I sopose I will switch to using Microsoft Visual Studio then but I really don't know if i like it enough but o well I gotta do what I gotta do so from now on I will just use Visual Studio oh and gavin williams you are right in some ways but I just don't like classes there just too object orientated and make it alot of work for each member of a class ;/
  20. no more chocolate drinks or chocolate I think I put too much cadburys milk powder into that drink ohh I feel tired and weird...
  • 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!