Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 19 Sep 2011
Offline Last Active Dec 08 2013 09:37 AM

Topics I've Started

[JAVA]First Game help[JAVA]

20 February 2013 - 08:25 PM

So for this game I want to make the ball to change direction when it hits the bottom of the screen. So i have 


public void ballmove()
    y += 1;


that moves it no problem but how would i make it go the opposite direction when it hits the top of the screen or bottom.

[2D Java Help] Need help with pong remake.[2D Java Help]

20 February 2013 - 01:43 PM

I need help makeing the ball hit the bottom and bouncing back up. I tried this but it just hits and stays in one spot which i know why but what else would i do?

public void ballmove()
			  y += 1;
			  if (y == 420)
				  y -= 1;



[SDL] Every time I move the mouse the sprite redraws need help.

06 December 2012 - 10:26 AM

I made my sprite move with the mouse but everytime I move it redraws to the screen what can I do to fix this?

[source lang="cpp"]#include "SDL/SDL.h"#include <stdbool.h>int x;int y;void apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination ){ SDL_Rect offset; offset.x = x; offset.y = y; SDL_BlitSurface(source, NULL, destination, &offset);}int main(int argc, char* args[]){ //images/ints SDL_Event event; SDL_Surface* sprite = NULL; SDL_Surface* back = NULL; SDL_Surface* screen = NULL; back = SDL_LoadBMP("back.bmp"); sprite = SDL_LoadBMP("char.bmp"); bool done = true; //init SDL_Init(SDL_INIT_EVERYTHING); screen = SDL_SetVideoMode(560, 560, 32, SDL_SWSURFACE); SDL_WM_SetCaption("Game", NULL); apply_surface(0, 0, back, screen); SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, SDL_MapRGB(sprite->format, 255, 0, 255)); while (done) { if (SDL_PollEvent(&event)) { if (event.type == SDL_QUIT) { done = false; } if(event.type == SDL_MOUSEMOTION) { x = event.motion.x; y = event.motion.y; apply_surface(x, y, sprite, screen); } } SDL_ShowCursor(SDL_DISABLE); SDL_Flip(screen); } SDL_FreeSurface(sprite); SDL_FreeSurface(back); return 0;}[/source]

[SFML] Need help with setting up sfml i cant find this error.

03 December 2012 - 07:28 PM

I was using SDL but i decided to switch to SFML so I did but i get an error of cannot fin -lSDLmain which is weird because i made a new project and changed all the settings to SFML. Im stuck can someone please help.

[SDL] Help with keyboard input and sprite movement

03 December 2012 - 01:34 PM

I'm new to SDL and I was wondering why this keyboard movement wasn't working.
[source lang="cpp"]#include "SDL/SDL.h"#include <stdbool.h>//SURFACES/variablesSDL_Surface *background = NULL;SDL_Surface *buffer = NULL;SDL_Surface *sprite = NULL;int y = 250;int x = 250;//applyvoid apply_surface(int x, int y, SDL_Surface* source, SDL_Surface* destination){SDL_Rect offset;offset.x = x;offset.y = y;SDL_BlitSurface(source, NULL, destination, &offset);}//startint main( int argc, char* args[] ){ //init SDL_Init( SDL_INIT_EVERYTHING ); background = SDL_LoadBMP("bg.bmp"); sprite = SDL_LoadBMP("char.bmp"); SDL_SetColorKey(sprite, SDL_SRCCOLORKEY, SDL_MapRGB(sprite->format, 230, 0, 230)); SDL_Event event; bool fullscreen = false; bool done = false; //loops if (fullscreen == false ) { buffer = SDL_SetVideoMode(500, 500, 32, SDL_SWSURFACE); } //APPNAME SDL_WM_SetCaption("Game", NULL); //apply surface/flips apply_surface(0, 0, background, buffer); apply_surface(x, y, sprite, buffer); SDL_Flip(buffer);//quitwhile(!done){ while(SDL_PollEvent (&event)) { switch (event.type) { case SDL_QUIT: { done = true; break; } case SDL_KEYDOWN: { if(event.key.keysym.sym == SDLK_DOWN) { y = y+1; } } } }}//END SDL_FreeSurface(background); SDL_FreeSurface(sprite); SDL_Quit(); return 0;}[/source]