Search Results

Search found 4022 results on 161 pages for 'float dublin'.

Page 57/161 | < Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >

  • Sprite not moving when using a function from another class SFML c++

    - by user2892932
    I have a Game.cpp, and I am calling a update function in my Player class. In my player update Function I have it to check for keyboard input, and it seems to work, but whenever I try to call the .move() function, it seems to not work. I get no errors either. I am new to sfml, and decent with c++. Help is appreciated! #include "Player.h" Player::Player(void): vel(0), maxvel(100) { Load("Assets/sss.png",true); } void Player::Update(sf::Sprite& p) { if (sf::Keyboard::isKeyPressed(sf::Keyboard::A)) { moveObject(-3,0, p); } if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) { moveObject(-3,0, p); } } Player::~Player(void) { } This is the GameObject cpp #include "GameObject.h" #include <iostream> GameObject::GameObject(void) { isLoaded = false; } void GameObject::Load(std::string flname, bool isPlayer) { if(!tex.loadFromFile(flname)) { EXIT_FAILURE; } else { if(isPlayer) { if(!tex.loadFromFile(flname, sf::IntRect(0,0,33,33))) { EXIT_FAILURE; } else { std::cout << "Loading image" << "\n"; filename = flname; spr.setTexture(tex); isLoaded = true; } } else { std::cout << "Loading image" << "\n"; filename = flname; spr.setTexture(tex); isLoaded = true; } } } void GameObject::Draw(sf::RenderWindow & window) { if(isLoaded) { window.draw(spr); window.display(); std::cout << "Sprite drew" << "\n"; } } void GameObject::setPos(float x, float y) { if(isLoaded) { spr.setPosition(x,y); } } sf::Vector2f GameObject::GetObjPos() { return spr.getPosition(); } sf::Sprite& GameObject::getSprite() { return spr; } void GameObject::moveObject(float x, float y, sf::Sprite& sp) { sp.move(x, y); } GameObject::~GameObject(void) { }

    Read the article

  • Footer getting jammed into a column

    - by chief
    I have a three column layout. The last column on the right is: #right_column { float: left; width: 7em; border: 1px solid #ccc; padding: 5px; } My footer is going into the bottom of my right column. If I remove the right column the footer is still misplaced in the page. I presume it is something related to the float.

    Read the article

  • Footer getting jammed into a column

    - by chief
    I have a three column layout. The last column on the right is: #right_column { float: left; width: 7em; border: 1px solid #ccc; padding: 5px; } My footer is going into the bottom of my right column. If I remove the right column the footer is still misplaced in the page. I presume it is something related to the float.

    Read the article

  • Problem in storing the dynamic data in NSMutableArray?

    - by Rajendra Bhole
    I want to develop an application in which firstly i was develop an structure code for storing X and y axis. struct TCo_ordinates { float x; float y; }; . Then in drawRect method i generating an object of structure like. struct TCo_ordinates *tCoordianates; Now I drawing the graph of Y-Axis its code is. fltX1 = 30; fltY1 = 5; fltX2 = fltX1; fltY2 = 270; CGContextMoveToPoint(ctx, fltX1, fltY1); CGContextAddLineToPoint(ctx, fltX2, fltY2); NSArray *hoursInDays = [[NSArray alloc] initWithObjects:@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"10",@"11",@"12", nil]; for(int intIndex = 0 ; intIndex < [hoursInDays count] ; fltY2-=20, intIndex++) { CGContextSetRGBStrokeColor(ctx, 2, 2, 2, 1); //CGContextSetRGBStrokeColor(ctx, 1.0f/255.0f, 1.0f/255.0f, 1.0f/255.0f, 1.0f); CGContextMoveToPoint(ctx, fltX1-3 , fltY2-40); CGContextAddLineToPoint(ctx, fltX1+3, fltY2-40); CGContextSelectFont(ctx, "Helvetica", 14.0, kCGEncodingMacRoman); CGContextSetTextDrawingMode(ctx, kCGTextFill); CGContextSetRGBFillColor(ctx, 0, 255, 255, 1); CGAffineTransform xform = CGAffineTransformMake( 1.0, 0.0, 0.0, -1.0, 0.0, 0.0); CGContextSetTextMatrix(ctx, xform); const char *arrayDataForYAxis = [[hoursInDays objectAtIndex:intIndex] UTF8String]; float x1 = fltX1-23; float y1 = fltY2-37; CGContextShowTextAtPoint(ctx, x1, y1, arrayDataForYAxis, strlen(arrayDataForYAxis)); CGContextStrokePath(ctx); Now i want to store generated the values of x1 and y1 in NSMutableArray dynamically, for that i was written the code. NSMutableArray *yAxisCoordinates = [[NSMutableArray alloc] autorelease]; for(int yObject = 0; yObject < intIndex; yObject++) { [yAxisCoordinates insertObject:(tCoordianates->x = x1,tCoordianates->y = y1) atIndex:yObject]; } But it didn't working. How i store the x1 and y1 values in yAxisCoordinates object. The above code is correct?????????????

    Read the article

  • CSS: Why do the border gets like this?

    - by Azzyh
    why does the border get like this, i want it around the videoclip, if i use float it do the border correctly, if i use position, then it gets like that, and i dont want to use float. #clip{ position: relative; right: 1px; border: 2px solid #FF3399; }

    Read the article

  • best way to find out type

    - by laspal
    hi, I have a dict val_dict - {'val1': 'abcd', 'val': '1234', 'val3': '1234.00', 'val4': '1abcd 2gfff'} All the values to my keys are string. So my question is how to find out type for my values in the dict. I mean if i say`int(val_dict['val1']) will give me error. Basically what I am trying to do is find out if the string is actual string or int or float.` if int( val_dict['val1'): dosomething else if float(val_dict['val1']): dosomething thanks

    Read the article

  • Converting a pointer C# type to F#??

    - by Brendon
    Hello all I am just a beginner in programing i wish covert some code from C# to F#, I have encotered this code: "float[] v1=new float[10]" I need to use this pointer to pass to the function: "ComputeBuffer bufV1 = new ComputeBuffer(Context, ComputeMemoryFlags.ReadWrite | ComputeMemoryFlags.UseHostPointer, v1);" If i creat an array in F# like this: "let v1 = [| 1.0..10.0 |]" and call now the funaction like this: "let bufV1 = new ComputeBuffer(Context, ComputeMemoryFlags.ReadWrite ||| ComputeMemoryFlags.UseHostPointer, v1)" Is it an error?? How do i pass a pointer??

    Read the article

  • [Visual C++]Forcing memory alignment of variables/data-structures

    - by John
    I'm looking at using SSE and I gather aligning data on 16byte boundaries is recommended. There are two cases to consider: float data[4]; struct myystruct { float x,y,z,w; }; I'm not sure the first case can be done explicitly, though there's perhaps a compiler option I could use? In the second case I remember being able to control packing in old versions of GCC several years back, is this still possible?

    Read the article

  • Animation not start immediately when the target view is out of window

    - by funnything
    Hi. When I apply some animation to the view, which is out of window, the animation not start immediately. And then, I scroll the screen to show the animation target view, the animation will start. I hope to the animation will start immediately when it apply. Any ideas? Bellow is sample code. Thank you. public class AnimationValidationActivity extends Activity { private ViewSwitcher _viewSwitcher; private Button _button; /** * utility method for animation */ private Animation buildTranslateAnimation( float fromXDelta , float toXDelta , float fromYDelta , float toYDelta ) { Animation ret = new TranslateAnimation( fromXDelta , toXDelta , fromYDelta , toYDelta ); ret.setDuration( 1000 ); return ret; } /** * build view in place of layout.xml */ private View buildView() { ScrollView ret = new ScrollView( this ); ret.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT , LinearLayout.LayoutParams.WRAP_CONTENT ) ); LinearLayout parent = new LinearLayout( this ); parent.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT , LinearLayout.LayoutParams.WRAP_CONTENT ) ); parent.setOrientation( LinearLayout.VERTICAL ); ret.addView( parent ); _viewSwitcher = new ViewSwitcher( this ); _viewSwitcher.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT , 100 ) ); parent.addView( _viewSwitcher ); View spacer = new View( this ); spacer.setLayoutParams( new LinearLayout.LayoutParams( LinearLayout.LayoutParams.FILL_PARENT , getWindow() .getWindowManager().getDefaultDisplay().getHeight() ) ); parent.addView( spacer ); _button = new Button( this ); _button.setText( "button" ); parent.addView( _button ); return ret; } @Override public void onCreate( Bundle savedInstanceState ) { super.onCreate( savedInstanceState ); setContentView( buildView() ); _viewSwitcher.setFactory( new ViewSwitcher.ViewFactory() { @Override public View makeView() { TextView view = new TextView( AnimationValidationActivity.this ); view.setLayoutParams( new ViewSwitcher.LayoutParams( ViewSwitcher.LayoutParams.FILL_PARENT , ViewSwitcher.LayoutParams.FILL_PARENT ) ); view.setBackgroundColor( 0xffffffff ); view.setText( "foobar" ); return view; } } ); _button.setOnClickListener( new View.OnClickListener() { @Override public void onClick( View v ) { _viewSwitcher.setInAnimation( buildTranslateAnimation( _viewSwitcher.getWidth() , 0 , 0 , 0 ) ); _viewSwitcher.setOutAnimation( buildTranslateAnimation( 0 , - _viewSwitcher.getWidth() , 0 , 0 ) ); int color = new Random().nextInt(); _viewSwitcher.getNextView().setBackgroundColor( 0xff000000 | color & 0xffffff ); _viewSwitcher.showNext(); } } ); } }

    Read the article

  • Regular Expression to parse SQL Structure

    - by user351429
    I am trying to parse the MySQL data types returned by "DESCRIBE [TABLE]". It returns strings like: int(11) float varchar(200) int(11) unsigned float(6,2) I've tried to do the job using regular expressions but it's not working. PHP CODE: $string = "int(11) numeric"; $regex = '/(\w+)\s*(\w+)/'; var_dump( preg_split($regex, $string) );

    Read the article

  • styling the data loaded from another page

    - by zurna
    Tabs plugin I use loads the data from another page. Data loaded is in xml format so I need to style that data loaded. How can I do it? ny suggestion highly appreciated. Data loaded needs to be used in the following: <img src="[ImageURL]" alt="" class="MultimediaImageURL" style="float:left; margin:0 10px 0 0;" /> <div class="MultimediaInfo" style="float:left; width:200px;"> <span class="MultimediaCategory" style="float:left; color:#CCC; font-size:10px; width:100%;">[CategoryName]</span> <span class="MultimediaTitle" style="float:left; color:#D90306; font-weight:bold; width:100%;">[Title]</span> tabs plugin $("div.row-title").tabs("div.panes", {effect: 'ajax'}, function(i) { // get the pane to be opened var pane = this.getPanes().eq(i); // load it with a page specified in the tab's href attribute pane.html('<img src="http://www.refinethetaste.com/FLPM/cp/images/loading.gif" alt="Loading..." />') .load(this.getTabs().eq(i).attr("href")); }); xml <rows> - <row id="1"> <MultimediaTitle>Hagi Goals</MultimediaTitle> <ImageURL>/FLPM/media/images/5Y2K4T5V_sm.jpg</ImageURL> - <Videos> - <VideoID id="1"> <VideoURL>/FLPM/media/videos/0H7T9C0F.flv</VideoURL> </VideoID> - <VideoID id="2"> <VideoURL>/FLPM/media/videos/9L6X9G9J.flv</VideoURL> </VideoID> </Videos> </row> </rows>

    Read the article

  • doing arithmetic upto two significant figures in Python?

    - by user248237
    I have two floats in Python that I'd like to subtract, i.e. v1 = float(value1) v2 = float(value2) diff = v1 - v2 I want "diff" to be computed upto two significant figures, that is compute it using %.2f of v1 and %.2f of v2. How can I do this? I know how to print v1 and v2 up to two decimals, but not how to do arithmetic like that. thanks.

    Read the article

  • How to handle null response for json object

    - by user1494754
    I get a JSON response as { "edges": [], "nodes": [] } how to check if the objects has null values and handle the case?? JSONObject jobj = new JSONObject(line); JSONArray jArray = jobj.getJSONArray("edges"); if(jArray.length()!=0) { for(int i=0;i<jArray.length();i++){ JSONObject json_data = jArray.getJSONObject(i); x.add((float) json_data.getInt("x")); y.add((float) json_data.getInt("y")); end This retrurns me : org.json.JSONException: end of input at character 0 of

    Read the article

  • How can i use a variable created in a objective c Void function?

    - by James
    Im trying to get the lat and long values generated in a void function and use them within another function. Any help grateful. (void)locationManager:(CLLocationManager *)manager didUpdateToLocation:(CLLocation *)newLocation fromLocation:(CLLocation *)oldLocation { float latDeg = newLocation.coordinate.latitude; NSLog(@"Lat: %g", latDeg); float longDeg = newLocation.coordinate.longitude; NSLog(@"Lat: %g", longDeg); } I want to use the latDeg and longDeg variables.

    Read the article

  • Find Label Control in Repeater Asp.net

    - by user2769165
    I am using repeater and I want to find the label control in my repeater. here is my code <asp:Repeater ID="friendRepeater" runat="server"> <table cellpadding="0" cellspacing="0"> <ItemTemplate> <tr style=" width:700px; height:120px;"> <td> <div style=" padding-left:180px;"> <div id="leftHandPost" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;"> <div id="childLeft" style=" padding-left:5px;"> <div id="photo" style=" border: thin solid black; width:100px;height:100px;"> <asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" /> </div> </div><!--childLeft--> </div><!--leftHandPost--> </div> </td> <td> <div id="rightHandPost" style=" float:right; padding-right:260px;"> <div id="childRight" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;"> <strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName") %></asp:Label></strong><br /> <div style=" float:right; padding-right:10px;"><asp:Button runat="server" Text="Add" onClick="add" /></div><br /> <asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br /> <asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label> </div><!--childRight--> </div><!--rightHandPost--> </td> </tr> </ItemTemplate> <AlternatingItemTemplate> <tr style=" width:700px; height:120px;"> <td> <div style=" padding-left:180px;"> <div id="Div1" style="float:left; width:120px; height:120px; border: medium solid #cdaf95; padding-top:5px;"> <div id="Div2" style="padding-left:5px;"> <div id="Div3" style=" border: thin solid black; width:100px;height:100px;"> <asp:Image id="photoImage" runat="server" ImageUrl='<%# String.Concat("Images/", Eval("Picture")) %>' Width="100px" Height="100px" /> </div> </div><!--childLeft--> </div><!--leftHandPost--> </div> </td> <td> <div id="Div4" style=" float:right; padding-right:260px;"> <div id="Div5" style="width:400px; height:120px; border: medium solid #cdaf95; padding-top:5px; padding-left:10px;"> <strong><asp:Label id="lblName" runat="server"><%# Eval("PersonName")%></asp:Label></strong> <div style=" float:right; padding-right:10px;"><asp:Button id="btnAdd" runat="server" Text="Add" onClick="add"></asp:Button></div><br /> <br /> <asp:Label id="lblID" runat="server"><%# Eval("PersonID") %></asp:Label><br /> <asp:Label id="lblEmail" runat="server"><%# Eval("Email") %></asp:Label> </div><!--childRight--> </div><!--rightHandPost--> </td> </tr> </AlternatingItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater> Here is the code behind for the add button. protected void add(object sender, EventArgs e) { DateTime date = DateTime.Now; System.Web.UI.WebControls.Label la = (System.Web.UI.WebControls.Label)friendRepeater.FindControl("PersonID"); String id = la.Text; try { MySqlConnection connStr = new MySqlConnection(); connStr.ConnectionString = "Server = localhost; Database = healthlivin; Uid = root; Pwd = khei92;"; String insertFriend = "INSERT INTO contactFriend(friendID, PersonID, PersonIDB, date) values (@id, @personIDA, @personIDB, @date)"; MySqlCommand cmdInsertStaff = new MySqlCommand(insertFriend, connStr); cmdInsertStaff.Parameters.AddWithValue("@id", "F000004"); cmdInsertStaff.Parameters.AddWithValue("@personIDA", "M000001"); cmdInsertStaff.Parameters.AddWithValue("@personIDB", id); cmdInsertStaff.Parameters.AddWithValue("@date", date); connStr.Open(); cmdInsertStaff.ExecuteNonQuery(); MessageBox.Show("inserted"); connStr.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } I have get the error of Object reference not set to an instance of an object. I think is because there are no value in the Label. The Find Control are not working. May I know how can fix this problem? Thank you very much

    Read the article

  • priority_queue with dynamic priorities

    - by Layne
    Hey, I have a server application which accepts incomming queries and executes them. If there are too many queries they should be queued and if some of the other queries got executed the queued queries should be executed as well. Since I want to pass queries with different priorities I think using a priority_queue would be the best choice. e.g. The amout of the axcepting queries (a) hit the limt and new queries will be stored in the queue. All queries have a priority of 1 (lowest) if some of the queries from (a) get executed the programm will pick the query with the highest priority out of the queue and execute it. Still no problem. Now someone is sending a query with a priority of 5 which gets added to the queue. Since this is the query with the highest priority the application will execute this query as soon as the running queries no longer hit the limit. There might be the worst case that 500 queries with a priority of 1 are queued but wont be executed since someone is always sending queries with a priority of 5 hence these 500 queries will be queued for a looooong time. In order to prevent that I want to increase the prioritiy of all queries which have a lower priority than the query with the higher priority, in this example which have a priority lower than 5. So if the query with a priority of 5 gets pulled out of the queue all other queries with a priority < 5 should be increased by 0.2. This way queries with a low priority wont be queued for ever even if there might be 100 queries with a higher priority. I really hope can help me to solve the problem with the priorities: Since my queries consist of an object I thought something like this might work: class Query { public: Query( std::string p_stQuery ) : stQuery( p_stQuery ) {}; std::string getQuery() const {return stQuery;}; void increasePriority( const float fIncrease ) {fPriority += fIncrease;}; friend bool operator < ( const Query& PriorityFirst, const Query& PriorityNext ) { if( PriorityFirst.fPriority < PriorityNext.fPriority ) { if( PriorityFirst.fStartPriority < PriorityNext.fStartPriority ) { Query qTemp = PriorityFirst; qTemp.increasePriority( INCREASE_RATE ); } return true; } else { return false; } }; private: static const float INCREASE_RATE = 0.2; float fPriority; // current priority float fStartPriority; // initialised priority std::string stQuery; };

    Read the article

  • CodeContracts: How to fullfill Require in Ctor using this() call?

    - by mafutrct
    I'm playing around with Microsoft's CodeContracts and encountered a problem I was unable to solve. I've got a class with two constructors: public Foo (public float f) { Contracts.Require(f > 0); } public Foo (int i) : this ((float)i) {} The example is simplified. I don't know how to check the second constructor's f for being 0. Is this even possible with Contracts?

    Read the article

  • Are 'const' variables precomputed by default in C++?

    - by Gunnar
    Suppose I have variables for positions like const float latitude = 51.+11./60.+33.0461/3600.; const float longitude = 12.+50./60.+31.9369/3600.; and use them frequently in the program. Does the compiler precompute that? (This example should not produce much overhead, but you get the point.) Bonus point for pointing out location. ;) TIA

    Read the article

  • Detect if class has overloaded function fails on Comeau compiler

    - by Frank
    Hi Everyone, I'm trying to use SFINAE to detect if a class has an overloaded member function that takes a certain type. The code I have seems to work correctly in Visual Studio and GCC, but does not compile using the Comeau online compiler. Here is the code I'm using: #include <stdio.h> //Comeau doesnt' have boost, so define our own enable_if_c template<bool value> struct enable_if_c { typedef void type; }; template<> struct enable_if_c< false > {}; //Class that has the overloaded member function class TestClass { public: void Func(float value) { printf( "%f\n", value ); } void Func(int value) { printf( "%i\n", value ); } }; //Struct to detect if TestClass has an overloaded member function for type T template<typename T> struct HasFunc { template<typename U, void (TestClass::*)( U )> struct SFINAE {}; template<typename U> static char Test(SFINAE<U, &TestClass::Func>*); template<typename U> static int Test(...); static const bool Has = sizeof(Test<T>(0)) == sizeof(char); }; //Use enable_if_c to only allow the function call if TestClass has a valid overload for T template<typename T> typename enable_if_c<HasFunc<T>::Has>::type CallFunc(TestClass &test, T value) { test.Func( value ); } int main() { float value1 = 0.0f; int value2 = 0; TestClass testClass; CallFunc( testClass, value1 ); //Should call TestClass::Func( float ) CallFunc( testClass, value2 ); //Should call TestClass::Func( int ) } The error message is: no instance of function template "CallFunc" matches the argument list. It seems that HasFunc::Has is false for int and float when it should be true. Is this a bug in the Comeau compiler? Am I doing something that's not standard? And if so, what do I need to do to fix it?

    Read the article

  • Rails 3.0 method_missing: undefined method in validator

    - by user567592
    == Schema Information Schema version: 20110111000403 # Table name: places # id :integer not null, primary key name :string(255) latitude :float longitude :float a place can be defined by latitude and longitude or by name # class Place < ActiveRecord::Base validates_precence_of :name, :if = lat_long_not_def? def lat_long_not_def? latitude.blank? || longitude.blank? end end

    Read the article

< Previous Page | 53 54 55 56 57 58 59 60 61 62 63 64  | Next Page >