Fight Simulator on Visual Basic 2010 made by Tansvanio

Users who are viewing this thread

Eheh. Well, I only had to do a small program and even tough VB has a lot of limitations when It comes to videogames, I decided to be a little creative and see what would come up. I think mine is far better than my colegues. They are doing stuff like buttons triggering image boxes and "Hello worlds"!
 
At my university my intro course was taught in python. (Partially because two of the department chairs wrote a well known python book.) Before we really even learned about true programming, we got to learn how to use a graphical plugin (library in C-speak) to make art images and animations. I mean right now in my spare time while I transition majors (I'm pre-med and was/am a bio major, don't officially switch to CS til next semester) I'm using python to make a better version of an evolution simulator one of my professors gave us. It's tricky sometimes, but already wrote the output to html parts of the raw data (with some limitations due to python's default outfile system) and am currently writing my own graphing app to automatically take the data and graph it.
 
tansvanio said:
I am not sure I even used a seed. I am quite new at these things. Here is the code I used.



Public Class Form1
    Dim Fighter1 As String
    Dim Fighter2 As String
    Dim Num1 As Single
    Public Class GlobalVariable
        Public Shared intVariable As Integer
    End Class






    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        Close()
    End Sub


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Fighter1 = CObj(TextBox1.Text)
        Fighter2 = CObj(TextBox2.Text)


Simulation_Start:
        If GlobalVariable.intVariable <= 19 Then
            'Add one to the intVariable
            GlobalVariable.intVariable = GlobalVariable.intVariable + 1
            'Do the common action
            Dim x As Integer
            Dim Num1 As Integer
            Randomize()


            For x = 1 To 20
                Num1 = Rnd() * 20


                If Num1 = 1 Then
                    RichTextBox1.Text = Fighter1 + " kicks " + Fighter2 + " in the stomach!"


                ElseIf Num1 = 2 Then
                    RichTextBox1.Text = Fighter2 + " kicks " + Fighter1 + " in the stomach!"


                ElseIf Num1 = 3 Then
                    RichTextBox1.Text = Fighter1 + " punches " + Fighter2 + " in his jaw!"


                ElseIf Num1 = 4 Then
                    RichTextBox1.Text = Fighter2 + " punches " + Fighter1 + " in his jaw!"


                ElseIf Num1 = 5 Then
                    RichTextBox1.Text = Fighter1 + " hits " + Fighter2 + " with a flying kick!"


                ElseIf Num1 = 6 Then
                    RichTextBox1.Text = Fighter2 + " hits " + Fighter1 + " with a flying kick!"


                ElseIf Num1 = 7 Then
                    RichTextBox1.Text = Fighter1 + " introduces his finger into " + Fighter2 + "´s eye! " + Fighter2 + " is half blind."


                ElseIf Num1 = 8 Then
                    RichTextBox1.Text = Fighter2 + " introduces his finger into " + Fighter1 + "´s eye! " + Fighter1 + " is half blind."


                ElseIf Num1 = 9 Then
                    RichTextBox1.Text = Fighter1 + " throws " + Fighter2 + " to the ground!"


                ElseIf Num1 = 10 Then
                    RichTextBox1.Text = Fighter2 + " throws " + Fighter1 + " to the ground!"


                ElseIf Num1 = 11 Then
                    RichTextBox1.Text = Fighter1 + " breaks " + Fighter2 + "´s nose! " + Fighter2 + " is bleeding!"


                ElseIf Num1 = 12 Then
                    RichTextBox1.Text = Fighter2 + " breaks " + Fighter1 + "´s nose! " + Fighter1 + " is bleeding!"


                ElseIf Num1 = 13 Then
                    RichTextBox1.Text = Fighter1 + " breaks " + Fighter2 + "´s arm!"


                ElseIf Num1 = 14 Then
                    RichTextBox1.Text = Fighter2 + " breaks " + Fighter1 + "´s arm!"


                ElseIf Num1 = 15 Then
                    RichTextBox1.Text = Fighter1 + " tries to choke " + Fighter2 + "!"


                ElseIf Num1 = 16 Then
                    RichTextBox1.Text = Fighter2 + " tries to choke " + Fighter1 + "!"


                ElseIf Num1 = 17 Then
                    RichTextBox1.Text = Fighter1 + " bites off " + Fighter2 + "´s ear!"


                ElseIf Num1 = 18 Then
                    RichTextBox1.Text = Fighter2 + " bites off " + Fighter1 + "´s ear!"


                End If




            Next


            If GlobalVariable.intVariable = 20 Then
                Button1.Text = "Finish him!"


                If Num1 = 19 Then
                    RichTextBox1.Text = Fighter1 + " punches " + Fighter2 + " in his balls! Ouch!"


                ElseIf Num1 = 20 Then
                    RichTextBox1.Text = Fighter2 + " punches " + Fighter1 + " in his balls! Ouch!"


                End If
            End If




            Else


                'Do the alternate action


                Dim x As Integer
                Dim Num1 As Integer
                Randomize()


                For x = 1 To 2
                    Num1 = Rnd() * 2


                If Num1 = 1 Then
                    RichTextBox1.Text = Fighter1 + " lands a punch so hard in " + Fighter2 + "´s head that he decapitates him!"
                    RichTextBox2.Text = Fighter1 + " wins!"
                    GoTo Simulation_Start


                ElseIf Num1 = 2 Then
                    RichTextBox1.Text = Fighter2 + " lands a punch so hard in " + Fighter1 + "´s head that he decapitates him!"
                    RichTextBox2.Text = Fighter2 + " wins!"
                    GoTo Simulation_Start


                End If


                Next
            End If
    End Sub




    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load


        'initalize the variable
        GlobalVariable.intVariable = 1


    End SubEnd Class

you could probably make this a lot simpler if you used arrays for the attacks and body parts
 
To Lerber: I want to know python some day eheh, would probably make modding warband a lot easier.


To Friendlyfyre: I will have to research on how to use arrays. At the moment I know nothing about them, I made this program with the resources I was taught in class. Only had about 180 minutes of class yet.
 
http://patorjk.com/programming/tutorials/vbarrays.htm

so it would be some thing like
Public i As Integer
Public strAtk (0 to 2) As String

strAtk (0) = "Punch"
strAtk (1) = "kick"
strAtk (2) = "headbutt"
i = 1

RichTextBox1.Text = strAtk (i)
this will print kick into your text box thing probably...
I don't really now visual basic so who knows its probably wrong  :neutral:
 
Python's pretty easy. From experience, it is in no way needed for modding. Most of the modding is, "copy, paste, modify value." However, python is pretty easy.

However, I can do a quick mock up of your thing here, it won't work, and won't function, but I"ll highlight the syntax for you (it's easy to relate projects.)

Code:
from Tkinter import * #Imports the gui stuff

class FormOne(self): #I think this is your gui's class
  def __init__(self): #called when the class is instatiated
    self.root = Tk() #create the gui foundation
    self.but1 = Button(self.root,text="Button 1",function="") #This creates a button, places text on it, and ties it to a function to call
    self.but1.grid(column=0,row=0) #this places it on the window

#The rest would take a long, long time to translate, but...
#In the main we'd instatiate the mainloop() which runs our gui and then go back up to classes and functions to do functionality.

mainform = Form1()
mainloop()

#We could also import cs1graphics which would let us draw scenes by code etc.
#white space is significant in python, it functions similar to curly brackets
 
Back
Top Bottom