generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: For you C++'ers

Previous Thread :: Next Thread 
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 02:24 PM
I am using SFML 2.0.
I have declared a sprite, and it works fine, except when I rotate it, it is on the wrong center point (orgin). I cannot figure out how to set the orgin. I have tried:


sf::Transformable::setOrigin ( const Vector2f & origin )


But it makes no sense to me. Help please
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 02:26 PM
just do it like

.setOrigin(sf::Vector2f(sizeX/2,sizeY/2));
Report Abuse
stravant is not online. stravant
Forum Moderator
Joined: 22 Oct 2007
Total Posts: 2893
10 Aug 2012 02:26 PM
What do you mean it "makes no sense to you"? Do you mean it doesn't do anything, or you don't know how to use it?
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 02:28 PM
And btw, I prefer using rectangles with textures instead of just sprites..
Report Abuse
Legend26 is not online. Legend26
Joined: 08 Sep 2008
Total Posts: 10586
10 Aug 2012 02:29 PM
How come Vector2f isn't shown in the documentation? There's a Vector2 templated class though...
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 02:30 PM
@Stravant
I didn't know how to use it.


I finally read a few pieces of code from 1.6 or whatever, then translated it to 2.0, And it works!

character.setOrigin(X,Y);

Thanks for helping guys!
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 02:34 PM
I have a new question:
What is the C++ equivalent of wait()
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 02:36 PM
you don't need wait. seriously.
if you want something to happen after certain amount of seconds just check the time from the game loop
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 02:37 PM
@su8
How? I am new-ish at C++
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 02:38 PM
And I want it to be a "jumping" action.
I press the up arrow key, sprite moves up for a set time, then down for a set time.
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 02:39 PM
uhm

sfml-dev.org/documentation/2.0/classsf_1_1Clock.php
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 02:41 PM
So this is what you basically want
(pseudo-code)

inair = false
last_jump = 0

while window is open
clear window
draw content
display window
if user input for jump
inair=true
last_jump = clock time
end
if inair then
if last_jump + delay > clock time
character y ++
else
character y --
end
if last_jump + delay*2 > clock time
inair = false
end
end
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 02:42 PM
ugh i meant

if last_jump + delay*2 < clock time
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 02:43 PM
and the delay is the time for the jump/get back down

sryfortriplepost
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 03:26 PM
I think I may have found a solution
int wait (int time)
{
bool iswaitover
sf::Clock:restart()
int e = sf::Clock::getElapsedTime()
if (e = time)
iswaitover = true
else
iswaitover = false
}
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 03:27 PM
no, you dont need that
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 03:27 PM
Owait. Maybe its this (My clock is named "clock"). I won't know until I try I guess

int wait (int time)
{
bool iswaitover
clock:restart()
int e = sf::Clock::getElapsedTime()
if (e = time)
iswaitover = true
else
iswaitover = false
}
Report Abuse
su8 is not online. su8
Joined: 06 Mar 2009
Total Posts: 6334
10 Aug 2012 03:29 PM
i posted the pseudo code derp
Report Abuse
booing is not online. booing
Joined: 04 May 2009
Total Posts: 6594
10 Aug 2012 03:30 PM
void wait(int t) {
cout << "k nob in " << t << " seconds press a key" << "\n";
system("pause");
cout << "noob" << "\n";
}
ya us ths it lik pro
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 03:51 PM
How do I store coordinates as a variable?
Report Abuse
IWantAFanta is not online. IWantAFanta
Joined: 27 Jul 2008
Total Posts: 7916
10 Aug 2012 03:53 PM
>2012
>not using D programming language
Report Abuse
FINALCRUSADE is not online. FINALCRUSADE
Joined: 09 Aug 2012
Total Posts: 27
10 Aug 2012 03:53 PM
>Not using D programming language.
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
10 Aug 2012 03:54 PM
There are multiple ways possible to do that, but here's two:

int x = ..., y = ..., z = ...;

Or:

int coordinate[3] = {x, y ,z};

You can also make a map:


int coordinates[2][3] = {{x, y, z}, {x, y ,z}};
Report Abuse
jordan4762 is not online. jordan4762
Joined: 08 Sep 2008
Total Posts: 4116
10 Aug 2012 03:56 PM
Umm, whut?

I am using SFML. It is 2D, so only X and Y.

I use characteer:getPosition()
Report Abuse
TheMyrco is not online. TheMyrco
Joined: 13 Aug 2011
Total Posts: 15105
10 Aug 2012 03:57 PM
A class is possible too:

class coordinate
{
public:
int x, y, z;
coordinate(): X = 0, Y = 0, Z = 0 {}
coordinate(int x, int y, int z): X = x, Y = y, Z = z {}
}
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image