Search Results

Search found 4835 results on 194 pages for 'coding hero'.

Page 24/194 | < Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >

  • is there any programming language that can bring together edit and compile / run ???

    - by Aff
    When I code, I always write little pieces of unit, and compile it often. This helps me to make sure that everything run correctly, but it's very time consumed. is there any programming language that can support us to do coding and running at the same time side by side ? i mean as soon as a key press leads to valid code, the effect of the edit is incorporated into the executing program.

    Read the article

  • C++: Calling class functions within a switch

    - by user1446002
    i've been trying to study for my finals by practicing classes and inheritance, this is what I've come up with so far for inheritance and such however I'm unsure how to fix the error occuring below. #include<iostream> #include<iomanip> #include<cmath> #include<string.h> using namespace std; //BASE CLASS DEFINITION class hero { protected: string name; string mainAttr; int xp; double hp; double mana; double armour; int range; double attkDmg; bool attkType; public: void dumpData(); void getName(); void getMainAttr(); void getAttkData(); void setAttkData(string); void setBasics(string, string, double, double, double); void levelUp(); }; //CLASS FUNCTIONS void hero::dumpData() { cout << "Name: " << name << endl; cout << "Main Attribute: " << mainAttr << endl; cout << "XP: " << xp << endl; cout << "HP: " << hp << endl; cout << "Mana: " << mana << endl; cout << "Armour: " << armour << endl; cout << "Attack Range: " << range << endl; cout << "Attack Damage: " << attkDmg << endl; cout << "Attack Type: " << attkType << endl << endl; } void hero::getName() { cout << "Name: " << name << endl; } void hero::getMainAttr() { cout << "Main Attribute: " << mainAttr << endl; } void hero::getAttkData() { cout << "Attack Range: " << range << endl; cout << "Attack Damage: " << attkDmg << endl; cout << "Attack Type: " << attkType << endl; } void hero::setAttkData(string attr) { int choice = 0; if (attr == "Strength") { choice = 1; } if (attr == "Agility") { choice = 2; } if (attr == "Intelligence") { choice = 3; } switch (choice) { case 1: range = 128; attkDmg = 80.0; attkType = 0; break; case 2: range = 350; attkDmg = 60.0; attkType = 0; break; case 3: range = 600; attkDmg = 35.0; attkType = 1; break; default: break; } } void hero::setBasics(string heroName, string attribute, double health, double mp, double armourVal) { name = heroName; mainAttr = attribute; hp = health; mana = mp; armour = armourVal; } void hero::levelUp() { xp = 0; hp = hp + (hp * 0.1); mana = mana + (mana * 0.1); armour = armour + ((armour*0.1) + 1); attkDmg = attkDmg + (attkDmg * 0.05); } //INHERITED CLASS DEFINITION class neutHero : protected hero { protected: string drops; int xpGain; public: int giveXP(int); void dropItems(); }; //INHERITED CLASS FUNCTIONS int neutHero::giveXP(int exp) { xp += exp; } void neutHero::dropItems() { cout << name << " has dropped the following items: " << endl; cout << drops << endl; } /* END OF OO! */ //FUNCTION PROTOTYPES void dispMenu(); int main() { int exit=0, choice=0, mainAttrChoice=0, heroCreated=0; double health, mp, armourVal; string heroName, attribute; do { dispMenu(); cin >> choice; switch (choice) { case 1: system("cls"); cout << "Please enter your hero name: "; cin >> heroName; cout << "\nPlease enter your primary attribute\n"; cout << "1. Strength\n" << "2. Agility\n" << "3. Intelligence\n"; cin >> mainAttrChoice; switch (mainAttrChoice) { case 1: attribute = "Strength"; health = 750; mp = 150; armourVal = 2; break; case 2: attribute = "Agility"; health = 550; mp = 200; armourVal = 6; break; case 3: attribute = "Intelligence"; health = 450; mp = 450; armourVal = 1; break; default: cout << "Choice invalid, please try again."; exit = 1; break; hero player; player.setBasics(heroName, attribute, health, mp, armourVal); player.setAttkData(attribute); heroCreated=1; system("cls"); cout << "Your hero has been created!\n\n"; player.dumpData(); system("pause"); break; } case 2: system("cls"); if (heroCreated == 1) { cout << "Your hero has been detailed below.\n\n"; **player.dumpData(); //ERROR OCCURS HERE !** system("pause"); } else { cout << "You have not created a hero please exit this prompt " "and press 1 on the menu to create a hero."; } break; case 3: system("cls"); cout << "Still Under Development"; system("pause"); break; case 4: system("cls"); exit = 1; break; default: cout << "Your command has not been recognised, please try again.\n"; system("pause"); break; } } while (exit != 1); system("pause"); return 0; } void dispMenu() { system("cls"); cout << "1. Create New Hero\n" "2. View Current Hero\n" "3. Fight Stuff\n" "4. Exit\n\n" "Enter your choice: "; } However upon compilation I get the following errors: 220 `player' undeclared (first use this function) Unsure exactly how to fix it as I've only recently started using OO approach. The error has a comment next to it above and is in case 2 in the main. Cheers guys.

    Read the article

  • 2d, Top-down map with different levels

    - by Ktash
    So, I'm creating a 2d, top down, sprite based (tiled) game, and right now I'm working on maps (well, a map editor at the moment, but it will be creating my maps, so basically the same thing). The scenario So, I'm thinking about efficiency and creating a map in pieces. In each piece, I plan on having 'layers'. Basically, I plan on rendering it down to a 'below hero' level, and an 'above hero' level, with the hero rendered in between obviously. There will likely also be a 'on level with hero' layer, but I'm not quite there yet. Not even worrying about events or interaction yet. Just looking to get a hero on the screen. Now for movement, I obviously need to know what tiles can be moved and in what direction. My plan at the moment is each tile getting 8 bits (4 'can enter in direction' bits, 4 'can leave in direction'). This will allow me to limit movement and even allow one way directional movement. The dilemma This works great for a lot of scenarios. It will allow me to store a map in essentially 3 layers, a string, and gives me flexibility going forward. However, I can't create maps that themselves have layers. A good example is a bridge where the user can go under or over the bridge without invalid moves being allowed. I can't create a platform and allow movement underneath. These are things I would like to be able to include in my game. My idea In theory, I could allow multiple hero layers and then allow multiple sets of 'below' and 'above' layers (or sandwich layers). But this complicates my system, and makes movement between maps potentially tricky (If the hero is on the third layer at the edge of a map, but that corresponds to the second layer on the other map, how can I allow or disallow movement). My question Is there a better way to manage multiple maps with multiple levels like this where a users level may be 'connected' on different levels on different maps? Or even... Am I doing this the hard way? Is there a more standard way to handle top-down 2d tiled maps that I am just not aware of? Things to note or that might be helpful This will be done in Javascript (transferred around in JSON) State will need to be transferred quickly, so a map-id and x/y/direction should be enough to get me a boolean 'can move' value Maps will not be standard sized (though they will be in a certain number of tiles) Making an editor tool so that I can have others help, so something that I can create in a tool would be helpful 'Teleportation' locations will likely need to exist to get into building maps and to and from different map sets (which will not necessarily be connected), but have not been created yet (lumping in with events at the moment).

    Read the article

  • ruby/ruby on rails memory leak detection

    - by Josh Moore
    I wrote a small web app using ruby on rails, its main purpose is to upload, store, and display results from xml(files can be up to several MB) files. After running for about 2 months I noticed that the mongrel process was using about 4GB of memory. I did some research on debugging ruby memory leaks and could not find much. So I have two questions. Are there any good tools that can be used to find memory leaks in Ruby/rails? What type of coding patterns cause memory leaks in ruby?

    Read the article

  • Parse HTML file to grab all ID and Classes for a CSS file

    - by iamfriendly
    Hey all, A short while ago, I'm fairly certain I came across an application (or perhaps a plugin for Coda - the IDE I use) which quickly parses a html document and then spits out all of the elements with IDs and Classes for me to use in a CSS file. Having fully 'got into' zen coding - using the wonderful TEA plugin for Coda, I'm now hot on the heels of this app/plugin again. I've tried and failed miserably at hunting through Google, but have come up completely empty handed. Does anyone know of anything which can do this? Happy New Year everyone!

    Read the article

  • Is there a code style enforcer?

    - by Petruza
    I'm working with websites written in PHP, along with many other programmers, and sometimes I have to deal with really awful code. Indentation totally messed up, curly braces in the wrong places, terrible whitespace use, it really hurts my eyes and actually makes my work harder and take longer. Is there a tool where you can specify your coding style and then it applies it to files? I'm sure there must be such functions in different IDEs, but I need an independent tool as I code with simple notepads like Notepad++ or the like. ( if it's such a function in Notepad++, I didn't see it )

    Read the article

  • How does NSValue do its magic?

    - by Paperflyer
    I have an MVC application. The model has a property that is a struct NSSize. It is writable like this: - (void)setSize:(NSSize)aSize; The view sets this NSSize using key-value-coding. However, you can not key-value-code a struct, so I wrapped it in an NSValue-object like this: [theView setValue:[NSValue valueWithSize:mySize] forKey:@"theModel.size"]; To my understanding, this should not work since the accessor expects a struct and not an NSValue. But it works perfectly. Magically. How is this possible?

    Read the article

  • Boolean Code Clarity - which style to use? [closed]

    - by Anonymous
    I was wondering what style others' use when writing conditional statements that include boolean types. Currently I'm caught between using two styles. bool foo; if (foo == true) if (foo) if (foo == false) if (!foo) Obviously the first set is a bit more obvious. However, when combining conditions it could get a bit clunky. if (foo == true || blah == false || abc == true) if (foo || !blah || abc) Switching between one style for short conditionals and the other for long conditionals seems like inconsistent coding so it seems like I'd have to choose between one or the other. What do you prefer or consider better style and why?

    Read the article

  • Can Eclipse parse and use emacs-style meta information in source code?

    - by ataylor
    In emacs, it is possible to start a file off with a line this: /* -*- mode: java; c-basic-offset: 4; indent-tabs-mode: nil -*- */ This instructs emacs to use 4 spaces for indentation. I like the idea of storing this coding style meta-information directly and explicitly in the source code. Are there any options for doing this in other IDEs? Does eclipse in particular have the ability to configure itself from a line in the emacs format or something equivalent?

    Read the article

  • Textmate tab and de-tab selected block

    - by Derek Organ
    Recently switched to Textmate on Mac for coding. On PC when ever I want to tab in or out a block of code I just highlight and press tab or shift+tab to move it in our out. It's very useful when you are adding an extra loop or conditional statement to a block of code to keep everything tidy and neatly indented. On Textmate however when I try this it just replaces my selected text with a tab. So is there a way to do tab and de-tab lines of code in textmate?

    Read the article

  • code-style: Is inline initialization of JS objects ok?

    - by michael
    I often find myself using inline initialization (see example below), especially in a switch statement when I don't know which case loop will hit. I find it easier to read than if statements. But is this good practice or will it incur side-effects or a performance hit? for (var i in array) { var o = o ? o : {}; // init object if it doesn't exist o[array[i]] = 1; // add key-values } Is there a good website to go to get coding style tips?

    Read the article

  • What should I read to improve my C++ style

    - by Victor Ronin
    I was developing for quite long time already on C/C++ (mostly C, which makes style poorer). So, I know how to use it. However, quite often I stuck with style decisions like: - should I return error code here, throw exceptions, return error through a parameter - should I have all this stuff in constructor or should I create separate init function for that. and so on. Any solutions WILL work. However, each of them has cons and pros, which I know and most importantly which I don't know. It would be very nice to read something regarding overall C++ development style, coding practices and so forth. What do you recommend?

    Read the article

  • Why do so many mathematicians format code so poorly? [closed]

    - by marcog
    I have done a fair amount of programming together with mathematicians. Now I am even teaching some high school kids coming from a mathematics background how to program. Most of these people format their code so hideously it's hard to believe. I've even worked with and taught mathematicians who will fight the auto-indenter! Why is this so common amongst mathematicians? BTW, this is one reason I have started teaching Python. Yet still they find ways other than indentation to produce whacked coding styles!

    Read the article

  • High level programming logic, design, pattern

    - by Muhammad Shahzad
    I have been doing programming from last 7 years, getting better and better, but still i think that am lacking something. I have been doing work in JOOMLA, MAGENTO, WP, Custom PHP, Opencart, laravel, codeignitor. Sometimes i need to design logic for a huge database application, in the applications we need nesting loops and queries, although i follow OOPS standards, ORM etc, still i feel i need more robust coding designs. I need to know how can i improve these things, so that code remain neat, efficient and faster. Also how big webapps like facebook twitter tests there code speed? How high level programmers choose design patterns. If you can help me find something useful with examples?

    Read the article

  • Forced naming of parameters in python

    - by Mark Mayo
    In python you may have a function definition: def info(object, spacing=10, collapse=1) which could be called in any of the following ways: info(odbchelper) info(odbchelper, 12) info(odbchelper, collapse=0) info(spacing=15, object=odbchelper) thanks to python's allowing of any-order arguments, so long as they're named. The problem we're having is as some of our larger functions grow, people might be adding parameters between spacing and collapse, meaning that the wrong values may be going to parameters that aren't named. In addition sometimes it's not always clear as to what needs to go in. We're after a way to force people to name certain parameters - not just a coding standard, but ideally a flag or pydev plugin? so that in the above 4 examples, only the last would pass the check as all the parameters are named. Odds are we'll only turn it on for certain functions, but any suggestions as to how to implement this - or if it's even possible would be appreciated.

    Read the article

  • Should every class have its own namespace?

    - by thehouse
    Something that has been troubling me for a while: The current wisdom is that types should be kept in a namespace that only contains functions which are part of the type's non-member interface (see C++ Coding Standards Sutter and Alexandrescu or here) to prevent ADL pulling in unrelated definitions. Does this imply that all classes must have a namespace of their own? If we assume that a class may be augmented in the future by the addition of non-member functions, then it can never be safe to put two types in the same namespace as either one of them may introduce non-member functions that could interfere with the other. The reason I ask is that namespaces are becoming cumbersome for me. I'm writing a header-only library and I find myself using classes names such as project::component::class_name::class_name. Their implementations call helper functions but as these can't be in the same namespace they also have to be fully qualified!

    Read the article

  • Does a persons' first programming language affect their programming style and if so, how? [closed]

    - by Scott Walsh
    I was speaking to an experienced lecturer recently who told me he could usually tell which programming language a student had learnt to program in by looking at their coding style (more specifically, when programming in other languages to the one which they were most comfortable with). He said that there have been multiple times when he's witnessed students attempted to write C# in Prolog. So I began to wonder, what specific traits do people gain from their first (or favourite) language which are carried over into their overall programming style, and more interestingly what good or bad habits do you think people would benefit from or should be wary of when learning specific language?

    Read the article

  • Best way to check for nullable bool in a condition expression (if ...)

    - by FireSnake
    I was wondering what was the most clean and understandable syntax for doing condition checks on nullable bools. Is the following good or bad coding style? Is there a way to express the condition better/more cleanly? bool? nullableBool = true; if (nullableBool ?? false) { ... } else { ... } especially the if (nullableBool ?? false) part. I don't like the if (x.HasValue && x.Value) style ... (not sure whether the question has been asked before ... couldn't find something similar with the search)

    Read the article

  • C# new class with only single property : derive from base or encapsulate into new ?

    - by Gobol
    I've tried to be descriptive :) It's rather programming-style problem than coding problem in itself. Let's suppose we have : A: public class MyDict { public Dictionary<int,string> dict; // do custom-serialization of "dict" public void SaveToFile(...); // customized deserialization of "dict" public void LoadFromFile(...); } B: public class MyDict : Dictionary<int,string> { } Which option would be better in the matter of programming style ? class B: is to be de/serialized externally. Main problem is : is it better to create new class (which would have only one property - like opt A:) or to create a new class derived - like opt B: ? I don't want any other data processing than adding/removing and de/serializing to stream. Thanks in advance!

    Read the article

  • int vs const int&

    - by Valdo
    I've noticed that I usually use constant references as return values or arguments. I think the reason is that it works almost the same as using non-reference in the code. But it definitely takes more space and function declarations become longer. I'm OK with such code but I think some people my find it a bad programming style. What do you think? Is it worth writing const int& over int? I think it's optimized by the compiler anyway, so maybe I'm just wasting my time coding it, a?

    Read the article

  • including .h files.

    - by Max
    Suppose I have two .h files: A.h and B.h. Moreover, A.h includes B.h itself: B.h - declares class B. class B { ... }; A.h - declares class A, which uses class B. #include B.h class A { void SomeFunction(const B& b); }; Now, I have some .cpp file, that uses both A and B classes (B class maybe used not only in A::SomeFunction(B)) What are the pluses to include both A.h and B.h (instead of only A.h) from the perspective of design-patterns and coding style.

    Read the article

  • International multi-OS keyboard layout for both coding and surfing?

    - by rassie
    So yes, the problem has been raised in parts multiple times already. Still I'm looking for a keyboard layout that has the following features: Easy on fingers (Dvorak-like layouts welcome) Easy for coding Includes german characters (typing ä with AltGr-p is not ok). Works well with web-browsing (Ctrl-t and Ctrl-w on one hand, left one very much preferred, since that's where my ex-CapsLock, now Ctrl lies) Works well with default Emacs bindings Works on both Windows and Linux (at least easily installable) I've looked at Dvorak and Neo, they both have a "shortcut problem", i.e. web-browsing and most frequent Emacs combinations use both parts of the keyboard. Using right Ctrl is usually not an option, since it'll give me RSI much faster than keeping QWERTY/Z. Funnily enough, mirroring the default Neo layout would probably be enough for me. So, any ideas?

    Read the article

  • What's the best platform for blogging about coding? [closed]

    - by timday
    I'm toying with starting an occasional blog for posting odd bits of coding related stuff (mainly C++, probably). Are there any platforms which can be recommended as providing exceptionally good support (e.g syntax highlighting) for posting snippets of code ? (Or any to avoid because posting mono-spaced font blocks of text is a pain). Outcome: I accepted Josh K's answer because what I actually ended up doing was realizing I was more interested in articles than a blog style, getting back into LaTeX (after almost 20 years away from it), using the "listings" package for code, and pushing the HTML/PDF results to my ISP's static-hosting pages. (HTML generated using tex4ht). Kudos to the answers mentioning Wordpress, Tumblr and Jekyll; I spent some time looking into all of them.

    Read the article

< Previous Page | 20 21 22 23 24 25 26 27 28 29 30 31  | Next Page >