JavaScript Projects

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I decided that just reading through the whole book would really help me in learning JavaScript, so I decided I woulds start coding and trying to put in everything I've learning into the coding.

Problem is... I can't think of what to code. (Besides one little thing which I successfully did), but still. I'm out of ideas right now.

Any ideas?

Thanks.
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

This is a game I wrote a few years ago, recreate it. :)

Looking at the source isn't going to help much, the ways I did things are outdated and the code isn't formatted in an easy to read way.

It will be a good exercise for working with forms and updating elements with the DOM. :D
Attachments:
product-game.zip

(15.33 KiB) Downloaded 450 times

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Alright... one question though. What is the purpose of that game? How to win? I don't really understand the game.
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Then recreate it in a way that it's easier to understand. It would be a good exercise in usability. Get used to it, people will drop bombs like this on you all the time. :D
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I can't recreate what I don't understand. The story is:

Quote:
You've just been fired from your job at the fast food joint. With your last check & bill money you've got $1,000 to your name.
What are you going to do about it ?
Use the controls below to buy/sell goods, manage your bank account, & go to day labor for a few extra bucks a day & to pass time. You've got 90 days before collection agencies will have you thrown in jail, see if you've got what it takes to move Product.

I'm not really sure what I'm supposed to do... I might change it when i code it, I just want to know what you wanted it to be.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

I get it. It works a lot like the stock market. You buy items when they're cheap and then sell them when they're more expensive. You have to earn a certain amount of money before the 90 days is up by capitalizing on the products. The end result after your 90th day is your daily average of capital gain, you compete with yourself for the highest number. A great functionality would be a goal for the player to reach for a daily average, and a couple levels with a story line.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

I know how to play. I know you buy cheap and sell expensive. I just don't see the point. No matter what I get for the daily average I loose. I had $1200 daily average.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

:lol: I just realized... it's always going to be game over no matter what :lol:
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13502
  • Loc: Florida

Post 3+ Months Ago

Don't worry about how to play it so much as clicking buttons and figuring out what does what, then trying to recreate the functionality. :)
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Alright then. I got the buy and sell functions written. I just need to associate them with the price, add the max functionality and then create the stats.

Oh, and the bank thing. I still need to do that.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Alright this one aside (Not that I can't do it, I have some other project with a higher priority).

I need to make a movable DIV on my site... not only movable, but when a user goes from page to page, the div stays in that position (Not a pup-up since there are pup-up blockers).

I might resort to pup-ups if it goes down to it though... I"m hoping for a div though.

I think I would need some cookies to remember the position of the div.
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

cookies or ajax to post the position to a php file on the server.
  • spork
  • Brewmaster
  • Silver Member
  • User avatar
  • Posts: 6251
  • Loc: Seattle, WA

Post 3+ Months Ago

mindfullsilence wrote:
ajax to post the position to a php file on the server.

Waaaaaay overkill. A simple cookie is more than sufficient for storing simple state like this, unless for some reason we're going to persist it on a long-term basis, e.g. for individual users.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Cookies would be fine... this would only be as long as they are logged in on my site and using that particular feature.

Now I would need to learn how to make it movable, post those positions in the cookie, have the positions in the cookie editable in case the user moves the div again, and retrievable so the div would be in that page on a different page of the same site.

Is that all possible?
  • mindfullsilence
  • Professor
  • Professor
  • User avatar
  • Posts: 854

Post 3+ Months Ago

I'm sure it is. Just overwrite the original cookie with the new positions.
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8388
  • Loc: USA

Post 3+ Months Ago

Yeah, I got that part... I just have to find out how to dynamically retrieve the positions whenever the user moves the DIV...
  • marinepower123
  • Born
  • Born
  • marinepower123
  • Posts: 2

Post 3+ Months Ago

Hello, sorry for the necropost, but I just wanted to thank you for posting such an interesting javascript project. This was my first time using javascript and I think it turned out quite nicely.

I uploaded the result to my site if anyone wants to see:
cremelianwars dot com/experiments/Product%20Game/index.html

There are win / lose conditions now too. The default target value is $90k, so you need to make an average of $1000 a day to win.
  • Bigwebmaster
  • Site Admin
  • Site Admin
  • User avatar
  • Posts: 9089
  • Loc: Seattle, WA & Phoenix, AZ

Post 3+ Months Ago

I tried it out, seems to work great! I lost though, only made about $200 a day. Did you learn much during the process of re-creating the game?
  • marinepower123
  • Born
  • Born
  • marinepower123
  • Posts: 2

Post 3+ Months Ago

Thanks for trying it out! I did indeed learn quite a bit. Towards the beginning I was dynamically generating all of the javascript code using document.createElement(), but eventually realized that most of the html code can be generated beforehand and simply hidden until needed.

The one thing I'm still not sure about is how to best access the html elements. Throughout the code I've used document.getElementById(), document.getElementByTagName(), and element.childNodes[0].

Also, I accessed a couple of elements through their .className property, so I'm not sure if that's a good practice, since the .class essentially represents the visual display rather than the inner structure.

Post Information

  • Total Posts in this topic: 19 posts
  • Users browsing this forum: No registered users and 61 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.