Jump to content


  • Content Count

  • Joined

  • Last visited

Community Reputation

0 Neutral

About DerekBogie

  • Rank
  1. Alright, that makes more sense. How would you suggest using the getItem and setItem methods to be able to save 20 localStorage variables with this method and not need to overload the localStorage variables onto players memory? If possible I would like to find a way to save 20 different variables with different values with localstorage. without having to make a new localstorage variable for each different value. That is why I thought an array would work best.
  2. I am attempting to use a localStorage array as a set of 20 binary switches so to say. The entire length of the area will be set to 0 all the way thru and I need to be able to switch individual array elements to 1. Basically this is what I have started with in the beginning. localStorage.dragonEggs = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]; There are 20 eggs throughout the maps. When you find a certain one, lets say egg 4. In the function I used , localStorage.dragonEggs[3] = 1; I am not sure since it is a localStorage Variable if i can do it this way or not? when I
  3. I understand exactly what you mean, thank you. I was able to recode it to getHours and used it as a localStorage variable to keep track. Due to my game running two direct Iframes to play the game that was the only way that it would work to update the other iframe.
  4. I figured it out using your method.. it seems to do the job as needed. Basically here it is in a nutshell When you open a chest it checks this in the function; d = new Date(); playerChestTimer = d.getHours(); if (playerChestTimer >= 19) { localStorage.lastOpened = 0; }else { localStorage.lastOpened = playerChestTimer; } So if the live Hourly Timer get over the 19th hour it will simply make the lastOpened variable to 0. Then the onLoad function for the page checked both variables in this format if (playerChestTimer >= (localStorage.lastOpened + 4) && playe
  5. Ive been working with this for roughly an hour now and it works great except i can only get it to work with one chest. I have to be able to make this system work with a totla of 10 chests. How can i restructure it to do so? basically i am trying to work it like this. I put the, localStorage.lastOpened = new Date(); into the open treasure chest function. Also with this I add 1 to the localStorage.chests variable. I used your code like this if((new Date()).getTime() - localStorage.lastOpened.getTime() >= 14400000) {localStorage.chests = 0;} im using that on the body Onload function along w
  6. You guys have helped me tremendously and I have one more should be simply task. My game will display 6 treasure chests around the map.. When you open a treasure chest It will add 1 to the localStorage.chest variable to keep track of how many treasure chests you have opened. after you open 10 total chests the chests will all disapear until the 4 hour timer resets the variable. This way they cant refresh the page numerous times and keep getting treasure chests. I curently have this set up to keep track of the hours d = new Date(); playerChestTimer = d.getHours(); Can you help me to wri
  7. It seems since the main page hold the healthbar ID. The Iframe within that main page holds the functions to the enemy. So when you click the function within that Iframe it refuses to update the main page ID. I have been reading something such as parent.document.getElementById('frameid').contentWindow.somefunction() or window.frames['myIFrame'].contentDocument.getElementById('myIFrameElemId') But I dont know if this is what I am needing to fix my issue.
  8. I appreciate your help and time in speaking with me. I am a second year college student who hasn't even taken a javascript course yet so everything i am doing i am learning as i go. Basically I started to make this game to help understand the structure and basic concepts of javascript. I must say that though I do not know the correct methods or the proper minimizing steps to keep it clean and straight to the point, it is teaching me the basics to an extent. I will continue to look into these problems and troubleshoot them further.
  9. Thanks Ingolme, That helps to understand the basic structure a little more. I have attempted to make a function that depicts player damage, updates the healthbar, checks to see if the player is dead. But when that function is called it is not updating whatSoever. I beleive this has something to do with the healthbar function being nestled inside the iframe other than that function of the jelly monster. Basically the only way i have been able to get the desired results of the functions i need is by this. I have been attempting to rewrite the overall function of each monster to call a sep
  10. I decided to change it from maxhealth and implement the defense and strength. This feels really sloppish on the values but heres what i have for one function with one monster. please tell me there is an easier way to add the rest of the monsters with different values than writing each of these functions for each monster? Basically when you click on the animated monster it calls this function. function jelly(e){ var enemyHitDamage = Math.floor((Math.random() * 2) + 1); if (enemyHitDamage == 2) { // if random number between 1 to 2 lands on 2 you take damage
  11. I have it figured out thank you! The problem exactly was that the jelly function was nestled into the iframe while the health bar was on the main page. Basically what I had to do was on the main page place this in the onLoad function for that page. Now all i have to do is make a loop to keep track and update the main page from the new variable values of the localStorage.health. document.getElementById('healthSystem').style.width = localStorage.health+"%"; and to subtract health from the health bar i wrote this in the function for the jelly attack localStorage.health = Number(localStorage.
  12. You are absolutely right on placing the health bar on the same page instead of on the Iframe. I have to figure this one out as the iframe map where the monster is on moves with the mouse and the health bar needs to stay stationary liek the rest of the menus. As for refactoring the helmets I thought there could be an easier wya instead of writing an individual function for each helmet to buy and sell. Would I use a "case" system to detect the helmet then?
  13. This error i have no idea how to fix and really don't understand what is wrong Uncaught ReferenceError: e is not defined Basically when you click the Jelly Blob on the screen it will call the function (which isnt finished) listed below. //function called when you click on the jelly monsterfunction fightTwo(e){ // Below shows a number above the jelly monster showing the damage taken document.getElementById('fight2').innerHTML = " " + " 19"; //Below is SUPPOSE to update the Health Bar with the new % value document.getElementById('healthSystem').style.width = "30%"; // This Timeout call
  14. So basically if my pages are labeled, 1Map.html, 2Map.html, 3Map.html I need to list them in the CSS as such? #1Map #playerEggs { } If so thank you for that that will def help. Also One quick question. Would it help load faster without the inline Style rather than the seperate CSS? I just saved your html script and tried it and it works perfectly by itself. However everytime I implement it directly into mine it does nothing just like every other time. Do you possibly know of a different way i can achieve what i need for a health bar rather than this if i cannot get it to work?
  15. Each inline CSS is basically necessary as these same images show up in multiple different locations with different dimensions and locations Thank you for that link
  • Create New...