Jump to content

Hadien

Members
  • Content Count

    247
  • Joined

  • Last visited

Community Reputation

39 Excellent

About Hadien

  • Rank
    Member
  • Birthday 04/18/1986

Previous Fields

  • Languages
    C#, CSS, HTML, Javascript, Java, MySQL, PHP, Unity, Unreal Engine 4, VBA, XML

Profile Information

  • Location
    Orlando, where it rains every 5PM
  • Interests
    Games, food, and a lot of Diet Coke.
  1. Try and understand the design concept of MVC, or (Model-View-Controller). its a design pattern used in many software applications but is a very solid choice for most website applications. Model - Stores all the internal data that the application uses. e.g. the database for websites. View - What the end-user sees, experiences, and interacts with. e.g. the webpage in their browser. Controller - The internal software application that "controls" the information flow between the model and View. e.g. the server This mindset helps define the responsibilities of each section of the applicati
  2. this line is the problem: orangeCost = (5); in your example orangeCost was assigned to an anonymous function (Its attached to the orangeCost variable, but the function itself is unnamed). That offending line is actually overwriting the function you wrote, thus deleting it. So the orangeCost variable is no longer pointing to a function, but to a plain 'ol number 5. To call it correctly this should be the valid syntax: orangeCost(5); Javascript will see that and think "oh, so you want me to run a function that's stored in the 'orangeCost' variable and give that function the number 5".
  3. var rect = one.getBoundingClientRect();var DeltaX = e.offsetX - (rect.left+rect.width/2);var DeltaY = e.offsety - (rect.top+rect.height/2);var Magnitude = (DeltaX^2 + DeltaY^2)^Delta^0.5;//should provide a degree range of -89 to 270var degree = (DeltaY>0)?Math.arcsin(DeltaX/Magnitude) :180 - Math.arcsin(DeltaX/Magnitude); When I have some time I'll come back and provide some polished code, but now I have some work to do. hopefully you can use what I gave you. EDIT: So here is the fully updated code after I had the time to actually sit down and work with it
  4. its "simple" math really, run a google search on "graph arctan2" and choose images, you should see what going on from that. basically when the y input into Math.arctan2() approaches 0 the number becomes undefined and returns a NAN. use ArcSin instead. you'll need the X delta (which you already have and pathagorean therom to find the distance (the hypotenuse or magnitude) which the mouse is from the origin. then... Math.arcsin(deltaX/magnitude); you'll never want to use arctan (DeltaX/DeltaY) in this case as you'll have the risk of DeltaY nearing zero and giving you a div/0 error
  5. well its inside an elseif so you don't even need to test if the number of apples is less than 4,just if it greater than 1. inside the first "if" expression you test to see if the value is greater than or equal to 4. so if that didn't evaluate to true the value would already automatically be less than 4, checking again in the elseif would just be redundant
  6. you are using vanilla jQuery, for this to work as expected on touch screens use jQuery Mobile. For mobile screens you want to use jQuery Mobile's .on("tap",[function]) as the event handler. The beauty of this is that jQuery Mobile will adapt some functionality to PC. If someone loads the screen onto a PC the tap handler will behave like a click handler, preserving functionality. Also if you only want it to activate in the bottom corner then you'll need to move the handler from that <div class="panel"> to a small div inside the panel <div class="panel"> <div clas
  7. Hadien

    Debugging!

    the reason I didn't run into that problem in my code was because of how I wrote my event handlers that link to the methods. in your script you use add event listener window.addEventListener('load',mynamespace.init); here you have addEventListener reference the init function to window directly. addEventListener forces the this reference to point to the window object when it runs init in my script I wrapped the object methods inside a custom tailored callback function... /*.....*/ele.button.onclick = function(){ if(flipflop = !flipflop){ ele.button.innerHTML = ele.button.value =
  8. Glad to help! If you have any questions feel free to ask.
  9. Hadien

    Debugging!

    I'm not sure how you're having problems with the onerror scheme not showing you were a bug is happening, what browser are you using? Works just fine in chrome, when I add a simple throw in my functions, tells me exactly the line where the error happens and everything. Personally I use Chrome's developer tools to help me locate my bugs. simply open up the console and click on the error log and it zips you to the bug. There are two types of functions in OOP, "smart" functions and "dumb" functions. "dumber" functions tries to think as little as possible and only focus on one or two thing
  10. Hadien

    Debugging!

    remember the four basic qualities of Object-oriented programming: Inheritance, Composition, Encapsulation, and Polymorphism. Inheritance: Theres no true Inheritance in Javascript, you can only fake it through prototypes, but If you're not planning to extend the functionality then its not worth the effort in messing with prototypes. Composition: As a general rule in any language always favor using Composition over Inheritance. though you'll end up with an explosion of classes/objects to work with compared to inheritance, your code will be a lot more flexible. Javascript lacks an <&
  11. Could you post a link to the webpage with the problem so that we can see the entire issue you are having and thus provide the best solution tailored to you? Off the bat I can see you are using table tags to format your page, which could cause for some of the difficulties you have. but how serious depends on how you've set up the rest of the page and the CSS styles you're using. also this is not so much a Javascript problem as it sounds mostly like a CSS/HTML problem. catching the mouse via javascript can be done, but I'm not sure if you can map it to the playback speed of the player as
  12. Hadien

    Array problem

    Javascript uses references for non-primitive datatypes. when you had B1=A and B2 =A they both "point" to the same memory location of A. Javascript wants to save memory any chance it can so it uses direct references to avoid eating up memory for identical memory values. In order to copy the entire array to a new variable you'll need to manually walk through all its elements and assign them on by one, as dsonesuk demonstrates.
  13. Ingolme beat me to it. Its better to get more acquainted with object-oriented programming in general and not stay specific to any one language. That said, C++/C# and Java are the dominant languages when it comes to game dev. and much of the fundamentals that you would learn in C++ you can take to many many other languages, including javascript. the other way around is risky as javascript can lull you into a complacent style of programming by relying too much on letting Javascript handle the things you would worry about in other languages. and you may end up having to relearn some fundamen
  14. Hadien

    Debugging!

    oh got the dreaded else if chain, just a tip that if you find yourself making a chain like this there is usually a far more efficient way of doing this... by the way did you know that you have an encryption for "Z" in there three times? also what is the purpose the hey and lol variables? they're not used...here is a rewrite... var encoder={ encryptKey:{"a":"86832", "b":"11111", "c":"10101", "d":"13364", "e":"54272", "f":"48382", "g":"94702", "h":"47029","i":"74302", "j":"10111", "k":"13831", "l":"12434", "m":"13338", "n":"14352", "o":"15356", "p":"55316", "q":"37417", "r":"16478", "s":"99190
  15. sounds like just css alone solves 90% of your problems. <div class="container"><textarea class="overlay"></textarea><img src="" class="underlay"></div> .container{ position: absolute;} img.underlay{ position: absolute; z-index:0; background-color: red;// or whatever color or background-image you want... width:100%; height:100%; top:0;} textarea.overlay{ position: relative; opacity: 0.5; z-index:1;} then use what ever code you already have to resize the textarea.if you want them to stick the window without scrolling away simply switch contiainer's posit
×
×
  • Create New...