0

I'm writing a game in javascript, and I had the world generator running fine, but when I created a startup function to run multiple things at once, my code doesn't run at all anymore. Can anyone see my problem?

<head>
<title>Project Rust</title>
<!-- <link href="/YOUR_PATH/favicon.ico" rel="icon" type="image/x-icon" /> -->
<script src="Scripts/startup.js"></script>
<script src="Scripts/drawmap.js"></script>
<script src="Scripts/maps.js"></script>
<script src="Scripts/mapread.js"></script>
<script src="Scripts/mainchar.js"></script>
</head>
<body bgcolor="#BFE3FF" onload="startup()">
</body>

startup.js: startup(){ alert("start"); drawmap(Screen[0]); mainchar(); }

11
  • 4
    Hi Aidan, I think you should write function startup() {alert('start');} Commented Aug 24, 2012 at 15:15
  • Are you sure the startup.js is being loaded? Which browser are you using? Commented Aug 24, 2012 at 15:16
  • 1
    you need to add the word function = function startup(){alert("start"); drawmap(Screen[0]); mainchar();} Commented Aug 24, 2012 at 15:16
  • @Jeroen This wasn't written in JSfiddle, I'm doing it in notepad++. Commented Aug 24, 2012 at 15:17
  • 1
    @Aidan You can upload what you have written to jsfiddle, that way we can run it an see what's wrong Commented Aug 24, 2012 at 15:18

3 Answers 3

1

Try this:

function startup(){
    alert("start"); drawmap(Screen[0]); mainchar();
}
Sign up to request clarification or add additional context in comments.

Comments

0

You should set the type to the script tags:

<script type="text/javascript" src="Scripts/startup.js"></script>

Also, you need to use the function keyword to define a function in javascript:

function startup(){
  alert("start");
  drawmap(Screen[0]);
  mainchar();
}

If it's still now working, open your browser's javascript console and you should see the error.

1 Comment

HTML 5 makes the type attribute optional.
0

You are missing the function declaration in your startup.js

You need function startup(){ /*your code*/ }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.