Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - gaz99

Pages: [1]
1
Graphics / does sfml support 16 bit images ?
« on: November 20, 2013, 07:03:11 pm »
Hi,

I've been creating terrain from a height map in open gl using sfml to load the image in. I know you can't load in a 16 bit png so i've been trying jpeg but my terrain still get's the stair effect. Does sfml support 16 bit images ?

2
General / Collision checking problem?
« on: February 27, 2012, 06:24:49 pm »
ahhh thank you i did what you said and got it working didn't realise that was happening. Thank you again!

3
General / Collision checking problem?
« on: February 27, 2012, 02:03:13 am »
Hi i recently had problems with using rects but figured out what i was doing wrong now i'm still having problems detecting more than one collision at the same time. the following code allows collision with the red blocks and does react to the blue blocks but does not destroy them?

Code: [Select]

for(int x=0; x <60 ; ++x)
{
if((ballR.Intersects(rBLOCK.getRect(x))))
{
if (!(rBLOCK.getCollide(x))) //if not collided
{
_angle =  360.0f - (_angle - 180.0f);
if(_angle > 360.0f){ _angle -= 360.0f;}
moveByY = -moveByY;
rBLOCK.setCollide(x, true);
++ destroyedBlocks;

}
}

else if((ballR.Intersects(bBLOCK.getRect(x))))
{
if((!(bBLOCK.getCollide(x))))
{
_angle =  360.0f - (_angle - 180.0f);
if(_angle > 360.0f){ _angle -= 360.0f;}

moveByY = -moveByY;
bBLOCK.setCollide(x, true);
++ destroyedBlocks;
}
}
}



but if i change the else if to an if it  does destroy both blocks like it should however the ball does not bounce back like it should but instead keeps going until it collides with the top or edge of the screen.

Could anyone help me out ?
sorry if i haven't explained it properly.

4
Graphics / [SOLVED]Text printing across the screen ?
« on: February 08, 2012, 09:11:55 pm »
Ahhhh problem solved thank you very much.

5
Graphics / [SOLVED]Text printing across the screen ?
« on: February 08, 2012, 08:35:06 pm »
Hi thanks for the quick reply so i put the position in the draw function like you suggested and it does the same thing the first 0 is drawn at the position specified but then draws across the screen.

my game loop is this
Code: [Select]

void game::play()
{
// cout<<"playing\n"<<endl;

sf::Event currentEvent;
win.GetEvent(currentEvent);

switch(gameState)
{
case game::Splashing:
{
ShowSplash();
break;
}
case game::Playing:
{

win.Clear(sf::Color::Black);//clear screen
draw();//draw
updateAll();//update
//check for close
if(currentEvent.Type == sf::Event::Closed)
{
gameState = Exiting;
}
if((currentEvent.Type == sf::Event::KeyPressed) && (currentEvent.Key.Code == sf::Key::Escape))
{
gameState = Exiting;
}
break;
}

case game::Exiting:
{
win.Close();
break;
}
}
}

And the draw and update functions called

Code: [Select]

void game::draw()
{
//cout<<"Drawing \n"<<endl;
PATH.draw(win);//blocks
BALL1.draw(win);//ball
PLAYER1.draw(win);//player
SCOREB.draw(win);




}
void game::updateAll()
{

//cout<<"updating\n"<<endl;
PLAYER1.update(win);//player
BALL1.update(win, getPlayer(), getBlock());
SCOREB.getScore(BALL1);
cout<<SCOREB.playerScore<<endl;


}


i printed the player score to the console and it is showing correct and updating correctly so it's something to do with my string but i have no idea why this is happening.

6
Graphics / [SOLVED]Text printing across the screen ?
« on: February 08, 2012, 06:40:53 pm »
Hi i'm making a breakout clone and i'm trying to implement the score. I have it all working, however when i draw the text it doesn't draw it in the same place but instead draws it as if i was holding a number key down i.e
"000000000000000000000000000000000000" across the screen. I don't know why it's doing this any help would be apreciated Thanks.

heres the .cpp
Code: [Select]

#include "scoreboard.h"

scoreboard::scoreboard(){}

void scoreboard::init()
{
scoreboardIMG.LoadFromFile("Maze/assets/scoreboard.png");
scoreB = sf::Sprite (scoreboardIMG);
scoreB.SetPosition(800,0);

playerScore = 0;
    Cheeseburger.LoadFromFile("Maze/assets/andyb.ttf");
scoreText.SetFont(Cheeseburger);
scoreText.SetSize(15.f);
    scoreText.SetColor(sf::Color(0,0,255));
}

void scoreboard::draw(sf::RenderWindow& win)
{
win.Draw(scoreB);
win.Draw(scoreText);
}

void scoreboard::getScore(ball& ball)
{
playerScore = ball.getDestroyed() * 50;
pScore << playerScore;
scoreText.SetText(pScore.str());
scoreText.SetPosition(0.f, 320.f);
scoreText.Move(0.f,0.f);



}


and the
header
Code: [Select]

#ifndef SCOREBOARD_H
#define SCOREBOARD_H
#include<SFML\Graphics.hpp>
#include<sstream>
#include "ball.h"

class scoreboard
{
public:
scoreboard();
void init();
void draw(sf::RenderWindow&);
void getScore(ball&);

protected:
sf::Image scoreboardIMG;
sf::Sprite scoreB;
int playerScore;

sf::String scoreText;
sf::Font Cheeseburger;
std::ostringstream pScore;
};



#endif

7
General / How to reset Pong ?
« on: November 25, 2011, 03:04:08 am »
Hi i've recently been using c++ and sfml and have edited the pong example to include a score to 7 and then displays the text like in the example. I wanted to add the R button to reset and it does what i want it to do apart from when it resets the win or lose text is still displaying. I tried using App.clear but that didn't work. Could anyone help me out.

Thanks

Code: [Select]

if((Event.Type == sf::Event::KeyPressed) && (Event.Key.Code == sf::Key::R))
{
App.Clear();

p1_score = 0;
cpu_score = 0;
AITimer.Reset();
Restart = true;


}

Pages: [1]
anything