Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 mario game help needed
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
new




PostPosted: Sat Dec 18, 2004 3:50 am   Post subject: mario game help needed

this is my final asisnment..i'm trying to make a mario demo kinda game..
i just strated like yesterday...faced soo many problems
1) scrolling the map left and right
2) problems with ai


note: this is not completed....the yellow box is just like ma test..i'll have a mario pic and same witht the ai
some one plzz help me with this...mainly with scroling and ai.....



Final.zip
 Description:

Download
 Filename:  Final.zip
 Filesize:  64.41 KB
 Downloaded:  206 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
new




PostPosted: Sun Dec 19, 2004 12:09 am   Post subject: (No subject)

yo guys...u probably noticed the jump with gravity thread on the forum..it is for this game as well.....i some wat figured it out...but i nedd help in scroling the map and ai...plzz help i want to make a game like this


http://ww.smashits.com/games/g_frames.cfm?File=superm/tgf0001.html

or go here and click super m
http://ww.smashits.com/index.cfm?Page=Games
Neo




PostPosted: Sun Dec 19, 2004 1:50 am   Post subject: (No subject)

To scroll, you basically give x and y coords to the objects you want to scroll. When the player reaches the right side of the screen you want to decrease the x coords so taht the objects scroll to the left and vise-versa for when the player is on the left edge of the screen. Drawing the background on an jpg or bmp image and then scrolling the whole image isnt very efficeint. Heres some example code.
code:

View.Set ("graphics:400;200,nobuttonbar,offscreenonly")

var keys : array char of boolean
var playerX, playerY := 20.0
var blockX, blockY : array 1 .. 10 of int
for n : 1 .. 10
    blockX (n) := Rand.Int (0, maxx * 4)
    blockY (n) := Rand.Int (0, maxy)
end for

colourback (grey)
loop
    Input.KeyDown (keys)

    if keys (KEY_RIGHT_ARROW) then
        playerX += 1
    elsif keys (KEY_LEFT_ARROW) then
        playerX -= 1
    end if

    for n : 1 .. 10
        if playerX <= 10 then
            blockX (n) += 1
            playerX += 0.1
        elsif playerX >= maxx - 10 then
            blockX (n) -= 1
            playerX -= 0.1
        end if
        drawfillbox (blockX (n), blockY (n), blockX (n) + 50, blockY (n) + 20, green)
    end for

    drawfilloval (round (playerX), round (playerY), 10, 10, blue)

    delay (10)
    View.Update
    cls
end loop


Of course, in your game you wouldnt draw the blocks randomly. Instead you give them specific coordinates but you should get the idea from this example. To make it more efficient, dont draw the blocks if they are <0 or >maxx.
new




PostPosted: Sun Dec 19, 2004 9:50 am   Post subject: (No subject)

here you are randomly creating the boxes....and movieng them left or right accoring to the palce where the oval is....but i can do tat....coz...i'have to make ai's moving based on these blcks..if i randomized.....i dont think..i can make ai's....is there any other way.??

plz help..thx in advance
Cervantes




PostPosted: Sun Dec 19, 2004 10:02 am   Post subject: (No subject)

new wrote:
i'have to make ai's moving based on these blcks..if i randomized.....i dont think..i can make ai's....is there any other way.??

Neo wrote:
Of course, in your game you wouldnt draw the blocks randomly. Instead you give them specific coordinates but you should get the idea from this example.

Don't draw the blocks randomly.
Besides, Mario AI isn't really AI. It's more along the lines of making an object repeat a task (such as moving forward and jumping every 3.5 seconds) over and over again.
new




PostPosted: Mon Dec 20, 2004 3:20 am   Post subject: (No subject)

this is ma updated code..for the mario



setscreen ("graphics:400;300,offscreenonly")
const gravity := 0.1
const Friction := 0.99
var x, y, vy, vx : real
x := maxx / 2
y := 10
vx := 0
var jumping := false
var keys : array char of boolean
loop
Input.KeyDown (keys)
if keys (KEY_UP_ARROW) and ~jumping then
jumping := true
vy := 5
end if
if ~jumping then
if keys (KEY_RIGHT_ARROW) then
vx += 0.1
end if
if keys (KEY_LEFT_ARROW) then
vx -= 0.1
end if
end if
if jumping then
vy -= gravity
y += vy
end if
if y < 10 then
y := 10
jumping := false
end if
x += vx
if ~jumping then
vx *= Friction
end if
cls
drawfilloval (round (x), round (y), 10, 10, black)
View.Update
delay (5)
end loop


use this and the pics in the dowload above....

i'm planing to use wat do colour for collisoion detection....but it deosnt work though..so..if tat guy jumps under a block...he sud not go over the block..but he sud..hit it and fall down as well...i tried teh wat dot colour..it doesnt seem to work though....any tips?
Cervantes




PostPosted: Mon Dec 20, 2004 9:14 am   Post subject: (No subject)

Wait a minute... I recognize that code!
I hope, for your sake, you just pasted the wrong thing.
Anyways, tips for whatdotcolour collision. Read the whole thing: I think I explained it fairly well Wink
MihaiG




PostPosted: Mon Dec 20, 2004 2:06 pm   Post subject: (No subject)

he he he somehow the same codesame variable names...
Sponsor
Sponsor
Sponsor
sponsor
Carino




PostPosted: Mon Dec 20, 2004 4:39 pm   Post subject: (No subject)

The scrolling is pretty simple. Once the guy gets to certain point on the screen u scubtract or add to a variable, such as the x-position or w/e. This should scroll the background, and ofcourse, when hes at this position, don't add to the guys x position or else he will go off screen. AI is simple for this game, just use collision detection if u want. Once the guy hits a wall/block/w.e he goes in the opposite direction. Its simple. Think about it logically and linearly.
MihaiG




PostPosted: Mon Dec 20, 2004 5:19 pm   Post subject: (No subject)

try working it out on a sheet of paper pseudo code... like think what happens whne he oes near a wall?
he stops... so make a boudrie.... trust me pseudo code helps
new




PostPosted: Tue Dec 21, 2004 12:49 am   Post subject: (No subject)

i did make the ai move the other way when it hits the wall using whatdot colour..the problem is tat the ai has to be inside teh screen tat we see..or else it wont collide..it just keeps going....

man..so many problems in this game Sad
carino...made a similar game...i need his help desperately Crying or Very sad
Cervantes




PostPosted: Tue Dec 21, 2004 7:20 am   Post subject: (No subject)

for AI, don't use whatdotcolour collision detection. For your character, it could be a good idea, if done right.
Carino




PostPosted: Tue Dec 21, 2004 12:05 pm   Post subject: (No subject)

I didn't use whatdotcolour for the collision, i personally don't like it. I just used the box-style collision detection. It involves a lot of long if statements but it works well and accurately.
Cervantes




PostPosted: Tue Dec 21, 2004 3:03 pm   Post subject: (No subject)

Sure it works, but it's quite annoying to have to make THAT many if statements.
Your main character must interact with everything (or most things) in the environment. This is why it's a good idea to use whatdotcolour collision detection for the main character. Plus, it's entirely feasible because the main character is always "on screen".
For the enemies (who will probably be performing a set routine that has nothing to do with the status of your main character) should use if statements. The enemies don't even have to interact with their environment, they can just "happen" to turn around and walk in the other direction when they reach a wall. So, all you must do is use a little if statement to determine the location of the enemy and then reverse the direction, or do what you want to do.
Actually, you don't even have to perform any of these ifstatements until the enemy comes within sight of your main character. Just have a flag (a boolean variable) to signify whether the enemy is about to come onto the screen or if he has in the past (make the flag = true if the previous statement is true). If the flag is true, begin the if statement "AI".
I wonder if that's actually how Mario works, or if they had the AI working non-stop... Thinking
new




PostPosted: Thu Dec 23, 2004 10:06 pm   Post subject: (No subject)

u,,...thx wat abt teh jump on teh blocks...when i jump under a block...how to make the guy not continue with teh jump...but make him go down....
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 15 Posts ]
Jump to:   


Style:  
Search: