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

Username:   Password: 
 RegisterRegister   
 Need Help With RPG Shooting Game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
SNIPERDUDE




PostPosted: Wed Jul 26, 2006 1:29 pm   Post subject: Need Help With RPG Shooting Game

I am trying to create a shooting game (birds eye view) that ppl can play over a network or splitscreen. The trouble is that I'm trying to create it so the program reads a txt doc and draws tiles on the screen. The parts I'm confused about are:

1. scrolling (having a large map, the camera is fixed on the char)
2. locating the character (where on the map is the opponant/you)
3. shooting (locating the bullet on the map so when the bullet is
out of view, it still moves in a given direction and stops
when it hits the wall offscreen)

PLZ HELP
this technique is new to me and if there is an easier way, plz tell me how I should format it.

heres what I have so far:

code:

setscreen ("graphics:450;450,nobuttonbar,offscreenonly,nocursor")
var lvl, y, h : int
var tilemap : array 1 .. 30 of string
var tile : array 1 .. 225 of int
tile (1) := Pic.FileNew ("pics/ground/grass1.bmp")
tile (2) := Pic.FileNew ("pics/ground/grass2.bmp")
tile (3) := Pic.FileNew ("pics/ground/grass3.bmp")
tile (4) := Pic.FileNew ("pics/wall/stonewall1.bmp")
tile (5) := Pic.FileNew ("pics/wall/lava.bmp")
tile (6) := Pic.FileNew ("pics/wall/water1.bmp")
tile (7) := Pic.FileNew ("pics/ground/dirt.bmp")
tile (8) := Pic.FileNew ("pics/ground/dirt2.bmp")
tile (9) := Pic.FileNew ("pics/ground/dirt3.bmp")
tile (10) := Pic.FileNew ("pics/ground/woodfloor.bmp")
tile (11) := Pic.FileNew ("pics/ground/dirt4.bmp")
tile (12) := Pic.FileNew ("pics/ground/dirt5.bmp")
tile (13) := Pic.FileNew ("pics/wall/ocean.bmp")
tile (14) := Pic.FileNew ("pics/wall/water2.bmp")
tile (15) := Pic.FileNew ("pics/wall/tower1.bmp")
tile (16) := Pic.FileNew ("pics/wall/tower2.bmp")
tile (17) := Pic.FileNew ("pics/wall/tower3.bmp")
tile (18) := Pic.FileNew ("pics/wall/tower4.bmp")
tile (19) := Pic.FileNew ("pics/wall/tower5.bmp")
tile (20) := Pic.FileNew ("pics/wall/tower6.bmp")
tile (21) := Pic.FileNew ("pics/wall/tower7.bmp")
tile (22) := Pic.FileNew ("pics/wall/tower8.bmp")
tile (23) := Pic.FileNew ("pics/wall/tower9.bmp")
tile (24) := Pic.FileNew ("pics/wall/tower10.bmp")
tile (25) := Pic.FileNew ("pics/wall/tower11.bmp")
tile (26) := Pic.FileNew ("pics/wall/tower12.bmp")
tile (27) := Pic.FileNew ("pics/wall/tower13.bmp")
tile (28) := Pic.FileNew ("pics/wall/tower14.bmp")
tile (29) := Pic.FileNew ("pics/wall/tower15.bmp")
tile (30) := Pic.FileNew ("pics/wall/tower16.bmp")
tile (31) := Pic.FileNew ("pics/ground/black.bmp")
tile (32) := Pic.FileNew ("pics/ground/snow1.bmp")
tile (33) := Pic.FileNew ("pics/ground/snow2.bmp")
tile (34) := Pic.FileNew ("pics/ground/snow3.bmp")
tile (35) := Pic.FileNew ("pics/ground/snow4.bmp")
tile (36) := Pic.FileNew ("pics/ground/snow5.bmp")
tile (37) := Pic.FileNew ("pics/ground/snow6.bmp")
tile (38) := Pic.FileNew ("pics/ground/snow7.bmp")
tile (39) := Pic.FileNew ("pics/ground/snow8.bmp")
tile (40) := Pic.FileNew ("pics/ground/snow9.bmp")
tile (41) := Pic.FileNew ("pics/ground/floor1.bmp")
tile (42) := Pic.FileNew ("pics/ground/steel.bmp")
tile (43) := Pic.FileNew ("pics/ground/walk.bmp")
tile (44) := Pic.FileNew ("pics/wall/stop.bmp")
tile (45) := Pic.FileNew ("pics/ground/track1.bmp")
tile (46) := Pic.FileNew ("pics/ground/track2.bmp")
tile (47) := Pic.FileNew ("pics/ground/track3.bmp")
tile (48) := Pic.FileNew ("pics/ground/track4.bmp")
var tloc : array 1 .. 225 of int

open : lvl, "pics/lvl1.txt", get
for a : 1 .. 15
get : lvl, tilemap (a)
end for
close : lvl

for m : 1 .. 15
    for j : 1 .. 15
        var q : int := (j - 1) * 15 + m
        if tilemap (j) (m) = "1" then
            tloc (q) := 1
        elsif tilemap (j) (m) = "2" then
            tloc (q) := 2
        elsif tilemap (j) (m) = "3" then
            tloc (q) := 3
        elsif tilemap (j) (m) = "4" then
            tloc (q) := 4
        elsif tilemap (j) (m) = "5" then
            tloc (q) := 5
        elsif tilemap (j) (m) = "6" then
            tloc (q) := 6
        elsif tilemap (j) (m) = "7" then
            tloc (q) := 7
        elsif tilemap (j) (m) = "8" then
            tloc (q) := 8
        elsif tilemap (j) (m) = "9" then
            tloc (q) := 9
        elsif tilemap (j) (m) = "w" then
            tloc (q) := 10
        elsif tilemap (j) (m) = "a" then
            tloc (q) := 11
        elsif tilemap (j) (m) = "A" then
            tloc (q) := 12
        elsif tilemap (j) (m) = "b" then
            tloc (q) := 13
        elsif tilemap (j) (m) = "B" then
            tloc (q) := 14
        elsif tilemap (j) (m) = "c" then
            tloc (q) := 15
        elsif tilemap (j) (m) = "C" then
            tloc (q) := 16
        elsif tilemap (j) (m) = "d" then
            tloc (q) := 17
        elsif tilemap (j) (m) = "D" then
            tloc (q) := 18
        elsif tilemap (j) (m) = "e" then
            tloc (q) := 19
        elsif tilemap (j) (m) = "E" then
            tloc (q) := 20
        elsif tilemap (j) (m) = "f" then
            tloc (q) := 21
        elsif tilemap (j) (m) = "F" then
            tloc (q) := 22
        elsif tilemap (j) (m) = "g" then
            tloc (q) := 23
        elsif tilemap (j) (m) = "G" then
            tloc (q) := 24
        elsif tilemap (j) (m) = "h" then
            tloc (q) := 25
        elsif tilemap (j) (m) = "H" then
            tloc (q) := 26
        elsif tilemap (j) (m) = "i" then
            tloc (q) := 27
        elsif tilemap (j) (m) = "I" then
            tloc (q) := 28
        elsif tilemap (j) (m) = "j" then
            tloc (q) := 29
        elsif tilemap (j) (m) = "J" then
            tloc (q) := 30
        elsif tilemap (j) (m) = "k" then
            tloc (q) := 31
        elsif tilemap (j) (m) = "K" then
            tloc (q) := 32
        elsif tilemap (j) (m) = "l" then
            tloc (q) := 33
        elsif tilemap (j) (m) = "L" then
            tloc (q) := 34
        elsif tilemap (j) (m) = "m" then
            tloc (q) := 35
        elsif tilemap (j) (m) = "M" then
            tloc (q) := 36
        elsif tilemap (j) (m) = "n" then
            tloc (q) := 37
        elsif tilemap (j) (m) = "N" then
            tloc (q) := 38
        elsif tilemap (j) (m) = "o" then
            tloc (q) := 39
        elsif tilemap (j) (m) = "O" then
            tloc (q) := 40
        elsif tilemap (j) (m) = "p" then
            tloc (q) := 41
        elsif tilemap (j) (m) = "P" then
            tloc (q) := 42
        elsif tilemap (j) (m) = "q" then
            tloc (q) := 45
        elsif tilemap (j) (m) = "Q" then
            tloc (q) := 46
        elsif tilemap (j) (m) = "r" then
            tloc (q) := 47
        elsif tilemap (j) (m) = "R" then
            tloc (q) := 48
        end if
    end for
end for

loop
    y := 1
    h := 0
    for i : 1 .. 225
        if h = 15 then
            y += 1
        end if
        if h < 15 then
            h += 1
        else
            h := 1
        end if
        if tloc (i) = 1 or tloc (i) = 2 or tloc (i) = 3 or tloc (i) = 7 or tloc (i) = 8 or tloc (i) = 9 or tloc (i) = 10 or tloc (i) = 11 or tloc (i) = 12 or tloc (i) = 31 or tloc (i) = 32 or tloc (i) = 33 or tloc (i) = 34 or tloc (i) = 35 or tloc (i) = 36 or tloc (i) = 37 or tloc (i) = 38 or tloc (i) = 39 or tloc (i) = 40 or tloc (i) = 41 or tloc (i) = 42 then
            Pic.Draw (tile (43), (h) * 30 - 30, maxy - y * 30, 0)
        elsif tloc (i) = 4 or tloc (i) = 5 or tloc (i) = 6 or tloc (i) = 13 or tloc (i) = 14 or tloc (i) = 15 or tloc (i) = 16 or tloc (i) = 17 or tloc (i) = 18 or tloc (i) = 19 or tloc (i) = 20 or tloc (i) = 21 or tloc (i) = 22 or tloc (i) = 23 or tloc (i) = 24 or tloc (i) = 25 or tloc (i) = 26 or tloc (i) = 27 or tloc (i) = 28 or tloc (i) = 29 or tloc (i) = 30 then
            Pic.Draw (tile (44), (h) * 30 - 30, maxy - y * 30, 0)
        end if
    end for
    y := 1
    h := 0
    for i : 1 .. 225
        if h = 15 then
            y += 1
        end if
        if h < 15 then
            h += 1
        else
            h := 1
        end if
        for z : 1 .. 200
            if tloc (i) = z then
                Pic.Draw (tile (z), (h) * 30 - 30, maxy - y * 30, 0)
            end if
        end for
    end for
    View.Update
end loop



plz respond ASAP please and thank you.
Sponsor
Sponsor
Sponsor
sponsor
Albrecd




PostPosted: Wed Jul 26, 2006 1:57 pm   Post subject: (No subject)

I think that one thing you need to take into consideration that will help a lot with offscreen location and scrolling is that you can draw things at locations greater that the max screen size and less than zero, they just won`t appear because they are off the screen.
Delos




PostPosted: Wed Jul 26, 2006 2:03 pm   Post subject: (No subject)

Do not post titles in ALL CAPS. It's distracting and annoying. I've changed it for you this time, next time the topic will simply be locked.

- why does your map file contain numbers and letters? If you need more than 10 identifiers, simply have each token a few more digits long. For instance:
00 vs. 0
10^2 options vs. 10^1 options.
Thusways you'll not need to have that horribly eye-wrenching if-clause, but a simple for loop.
- comment your code. If I can't get a feeling of what's going on just by looking at it, I might not take the time to load it up into an interpretter. This case is a double whammy - not only can I not decypher most of what's going on, but I wouldn't be able to test it out either as you've got a bunch of pic declarations at the top...
MysticVegeta




PostPosted: Wed Jul 26, 2006 4:02 pm   Post subject: (No subject)

I would suggest you start out with non-network shooter. And please, learn how to use "for" loops. from title (15) to title (30) you are using towerx.jpg. Cant you use loops to simplify that? Also, What the heck is this?

if tilemap (j) (m) = "1" then
tloc (q) := 1
elsif tilemap (j) (m) = "2" then
tloc (q) := 2
elsif tilemap (j) (m) = "3" then
tloc (q) := 3
elsif tilemap (j) (m) = "4" then
tloc (q) := 4
elsif tilemap (j) (m) = "5" then
tloc (q) := 5
elsif tilemap (j) (m) = "6" then
tloc (q) := 6
elsif tilemap (j) (m) = "7" then
tloc (q) := 7
elsif tilemap (j) (m) = "8" then
tloc (q) := 8
elsif tilemap (j) (m) = "9" then
tloc (q) := 9
elsif tilemap (j) (m) = "w" then
tloc (q) := 10
elsif tilemap (j) (m) = "a" then
tloc (q) := 11
elsif tilemap (j) (m) = "A" then
tloc (q) := 12
elsif tilemap (j) (m) = "b" then
tloc (q) := 13
elsif tilemap (j) (m) = "B" then
tloc (q) := 14
elsif tilemap (j) (m) = "c" then
tloc (q) := 15
elsif tilemap (j) (m) = "C" then
tloc (q) := 16
elsif tilemap (j) (m) = "d" then
tloc (q) := 17
elsif tilemap (j) (m) = "D" then
tloc (q) := 18
elsif tilemap (j) (m) = "e" then
tloc (q) := 19
elsif tilemap (j) (m) = "E" then
tloc (q) := 20
elsif tilemap (j) (m) = "f" then
tloc (q) := 21
elsif tilemap (j) (m) = "F" then
tloc (q) := 22
elsif tilemap (j) (m) = "g" then
tloc (q) := 23
elsif tilemap (j) (m) = "G" then
tloc (q) := 24
elsif tilemap (j) (m) = "h" then
tloc (q) := 25
elsif tilemap (j) (m) = "H" then
tloc (q) := 26
elsif tilemap (j) (m) = "i" then
tloc (q) := 27
elsif tilemap (j) (m) = "I" then
tloc (q) := 28
elsif tilemap (j) (m) = "j" then
tloc (q) := 29
elsif tilemap (j) (m) = "J" then
tloc (q) := 30
elsif tilemap (j) (m) = "k" then
tloc (q) := 31
elsif tilemap (j) (m) = "K" then
tloc (q) := 32
elsif tilemap (j) (m) = "l" then
tloc (q) := 33
elsif tilemap (j) (m) = "L" then
tloc (q) := 34
elsif tilemap (j) (m) = "m" then
tloc (q) := 35
elsif tilemap (j) (m) = "M" then
tloc (q) := 36
elsif tilemap (j) (m) = "n" then
tloc (q) := 37
elsif tilemap (j) (m) = "N" then
tloc (q) := 38
elsif tilemap (j) (m) = "o" then
tloc (q) := 39
elsif tilemap (j) (m) = "O" then
tloc (q) := 40
elsif tilemap (j) (m) = "p" then
tloc (q) := 41
elsif tilemap (j) (m) = "P" then
tloc (q) := 42
elsif tilemap (j) (m) = "q" then
tloc (q) := 45
elsif tilemap (j) (m) = "Q" then
tloc (q) := 46
elsif tilemap (j) (m) = "r" then
tloc (q) := 47
elsif tilemap (j) (m) = "R" then
tloc (q) := 48

Cant you make 2 strings? Having corresponding values, then just use 1 more loop inside and sum everything up in 3 lines? Its really unreadable!
SNIPERDUDE




PostPosted: Wed Jul 26, 2006 4:35 pm   Post subject: (No subject)

srry bout all the confusion.

Starting from dcratch, whats the best way to approach making it?
Delos




PostPosted: Wed Jul 26, 2006 8:48 pm   Post subject: (No subject)

This post was made a few days ago and summarizes a very relevant approach (don't mind the aggressive tone in which it was written - there was ample reason for that :Lol:).
Essentially it comes down to planning before coding. It's oh-so-tempting to jump onboard and code to your heart's content, but you'll never get anywhere like that. Plan ahead, document your steps so you refer back later, and then code.
NikG




PostPosted: Wed Jul 26, 2006 10:22 pm   Post subject: (No subject)

Albrecd wrote:
I think that one thing you need to take into consideration that will help a lot with offscreen location and scrolling is that you can draw things at locations greater that the max screen size and less than zero, they just won`t appear because they are off the screen.
Although this is true, I wouldn't recommend it. Why bother drawing things if they will not be visible to the user?

In terms of your scrolling problem, the solution is simple. All you need is a couple of variables that keep track of where you are currently looking (let's call them ViewX and ViewY and assume it points to the middle of the screen). Then all you need to do is relate them to your map size (let's say MaxX and MaxY). Therefore if the size of your screen is 500x400 pixels, ViewX will range from 250 to MaxX-250 and ViewY will range from 200 to MaxY-200. Then you can simple check if an event is happening between ViewX-250 and ViewX+250 and between ViewY-200 and ViewY+200.
(Having read that over, I realize that that might not have been a very good explanation on my part. If you didn't understand, post here and I'll repeat myself in a better way. If you want an example, take a look at my RTS engine which also uses large maps with only certain areas visible.)
MysticVegeta




PostPosted: Thu Jul 27, 2006 11:05 am   Post subject: (No subject)

SNIPERDUDE wrote:
srry bout all the confusion.

Starting from dcratch, whats the best way to approach making it?


1) Take a paper, write down all the things that you can do in Turing.
2) Take another paper, write down all the things that you can learn with the current knowledge you have.
3) Write down the plans for game on another paper.
4) Write down what concepts that you know that the game will use, dont get all advanced and stuff.
5) Write down ideas on another.

--------------------------------------------------------------------------------------

6) Draw a tree of how things would work (look at the plan)
7) Start coding on paper and pencil and if you see it gets out of hands advanced. either learn better ways of doing it or replace the plan with another.
Sponsor
Sponsor
Sponsor
sponsor
SNIPERDUDE




PostPosted: Sat Jul 29, 2006 7:52 pm   Post subject: (No subject)

sounds reasonable, I'll try it out
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  [ 9 Posts ]
Jump to:   


Style:  
Search: